diff --git a/.editorconfig b/.editorconfig index 9452c5f..c746910 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,8 @@ +root = true +[*] charset = utf-8 indent_style = space -indent_size = 4 \ No newline at end of file +indent_size = 4 + +[makefile] +indent_style = tab \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cf562f..e618533 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,33 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + + - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 #v4.0.3 + with: + cache: npm + node-version-file: .node-version + - name: Install run: | npm install - - name: Check + - name: Format Check run: | - npm run check + npm run format.check + - name: Type Check + run: | + npm run typecheck - name: Test run: | npm test + +# - name: Integration Test - ESM Import - Install +# run: | +# npm install --install-links --prefix ./test-integration/esm-project +# - name: Integration Test - ESM Import - Test +# run: | +# npm run test --prefix ./test-integration/esm-project +# - name: Integration Test - CJS Import +# working-directory: ./test-integration/esm-project +# run: | +# npm install --install-links +# npm run test diff --git a/.node-version b/.node-version index 2c6984e..e222811 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -v22.19.0 +22.19.0 diff --git a/README.md b/README.md index c3d984e..be162ec 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,17 @@ Node-SDK is a TypeScript library to access [Docker engine API](https://docs.docker.com/reference/api/engine/#view-the-api-reference) (a.k.a "Moby"). +## Installation + +```bash +npm install @docker/node-sdk +``` + ## Usage ```typescript +import { DockerClient } from '@docker/node-sdk'; + const docker = await DockerClient.fromDockerConfig(); const containers = await docker.containerList({ all: true }); diff --git a/lib/docker-client.ts b/lib/docker-client.ts index 8883ee9..ed813e6 100644 --- a/lib/docker-client.ts +++ b/lib/docker-client.ts @@ -3,7 +3,6 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; import * as http from 'http'; -import * as https from 'https'; import * as tls from 'tls'; import * as models from './models/index.js'; import { HTTPClient } from './http.js'; @@ -13,18 +12,24 @@ import { SSH } from './ssh.js'; import { TLS } from './tls.js'; import * as stream from 'node:stream'; import { demultiplexStream } from './multiplexed-stream.js'; +import { + getErrorMessage, + isFileNotFoundError, + parseDockerHost, +} from './util.js'; -export class Credentials { +export interface Credentials { username: string; password: string; email: string; serveraddress: string; } -export class IdentityToken { +export interface IdentityToken { token: string; } +// noinspection JSUnusedGlobalSymbols export class DockerClient { private api: HTTPClient; @@ -55,15 +60,14 @@ export class DockerClient { } catch (error) { reject( new Error( - `Failed to create Docker client for ${dockerHost}: ${error.message}`, + `Failed to create Docker client for ${dockerHost}: ${getErrorMessage(error)}`, ), ); } } else if (dockerHost.startsWith('tcp:')) { // TCP connection - use SocketAgent with TCP socket creation function - const tcpAddress = dockerHost.substring(6); // Remove "tcp://" prefix - const [host, portStr] = tcpAddress.split(':'); - const port = parseInt(portStr) || (certPath ? 2376 : 2375); // Default ports: 2376 for TLS, 2375 for plain + const defaultPort = certPath ? 2376 : 2375; // Default ports: 2376 for TLS, 2375 for plain + const { host, port } = parseDockerHost(dockerHost, defaultPort); try { let agent: SocketAgent; @@ -85,7 +89,7 @@ export class DockerClient { } catch (error) { reject( new Error( - `Failed to create Docker client for ${dockerHost}: ${error.message}`, + `Failed to create Docker client for ${dockerHost}: ${getErrorMessage(error)}`, ), ); } @@ -99,7 +103,7 @@ export class DockerClient { } catch (error) { reject( new Error( - `Failed to create SSH Docker client for ${dockerHost}: ${error.message}`, + `Failed to create SSH Docker client for ${dockerHost}: ${getErrorMessage(error)}`, ), ); } @@ -177,13 +181,12 @@ export class DockerClient { } } catch (parseError) { // Skip invalid meta.json files - continue; } } throw new Error(`Docker context '${targetContext}' not found`); } catch (error) { - if (error.code === 'ENOENT') { + if (isFileNotFoundError(error)) { throw new Error( `Docker contexts directory not found: ${contextsDir}`, ); @@ -225,7 +228,7 @@ export class DockerClient { return DockerClient.fromDockerHost('unix:/var/run/docker.sock'); } } catch (error) { - if (error.code === 'ENOENT') { + if (isFileNotFoundError(error)) { // Config file doesn't exist, use default return DockerClient.fromDockerHost('unix:/var/run/docker.sock'); } else if (error instanceof SyntaxError) { @@ -278,9 +281,11 @@ export class DockerClient { /** * Stream real-time events from the server. Various objects within Docker report events when something happens to them. Containers report these events: `attach`, `commit`, `copy`, `create`, `destroy`, `detach`, `die`, `exec_create`, `exec_detach`, `exec_start`, `exec_die`, `export`, `health_status`, `kill`, `oom`, `pause`, `rename`, `resize`, `restart`, `start`, `stop`, `top`, `unpause`, `update`, and `prune` Images report these events: `create`, `delete`, `import`, `load`, `pull`, `push`, `save`, `tag`, `untag`, and `prune` Volumes report these events: `create`, `mount`, `unmount`, `destroy`, and `prune` Networks report these events: `create`, `connect`, `disconnect`, `destroy`, `update`, `remove`, and `prune` The Docker daemon reports these events: `reload` Services report these events: `create`, `update`, and `remove` Nodes report these events: `create`, `update`, and `remove` Secrets report these events: `create`, `update`, and `remove` Configs report these events: `create`, `update`, and `remove` The Builder reports `prune` events * Monitor events - * @param since Show events created since this timestamp then stream new events. - * @param until Show events created until this timestamp then stop streaming. - * @param filters Filters to process on the event list. Available filters: - 'config' config name or ID - 'container' container name or ID - 'daemon' daemon name or ID - 'event' event type - 'image' image name or ID - 'label' image or container label - 'network' network name or ID - 'node' node ID - 'plugin' plugin name or ID - 'scope' local or swarm - 'secret' secret name or ID - 'service' service name or ID - 'type' object to filter by, one of 'container', 'image', 'volume', 'network', 'daemon', 'plugin', 'node', 'service', 'secret' or 'config' - 'volume' volume name + * @param callback + * @param options + * @param options.since Show events created since this timestamp then stream new events. + * @param options.until Show events created until this timestamp then stop streaming. + * @param options.filters Filters to process on the event list. Available filters: - 'config' config name or ID - 'container' container name or ID - 'daemon' daemon name or ID - 'event' event type - 'image' image name or ID - 'label' image or container label - 'network' network name or ID - 'node' node ID - 'plugin' plugin name or ID - 'scope' local or swarm - 'secret' secret name or ID - 'service' service name or ID - 'type' object to filter by, one of 'container', 'image', 'volume', 'network', 'daemon', 'plugin', 'node', 'service', 'secret' or 'config' - 'volume' volume name */ public async systemEvents( callback: (event: models.EventMessage) => void, @@ -378,12 +383,15 @@ export class DockerClient { * Attach to a container to read its output or send it input. You can attach to the same container multiple times and you can reattach to containers that have been detached. Either the `stream` or `logs` parameter must be `true` for this endpoint to do anything. See the [documentation for the `docker attach` command](https://docs.docker.com/engine/reference/commandline/attach/) for more details. ### Hijacking This endpoint hijacks the HTTP connection to transport `stdin`, `stdout`, and `stderr` on the same socket. This is the response from the daemon for an attach request: ``` HTTP/1.1 200 OK Content-Type: application/vnd.docker.raw-stream [STREAM] ``` After the headers and two new lines, the TCP connection can now be used for raw, bidirectional communication between the client and server. To hint potential proxies about connection hijacking, the Docker client can also optionally send connection upgrade headers. For example, the client sends this request to upgrade the connection: ``` POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1 Upgrade: tcp Connection: Upgrade ``` The Docker daemon will respond with a `101 UPGRADED` response, and will similarly follow with the raw stream: ``` HTTP/1.1 101 UPGRADED Content-Type: application/vnd.docker.raw-stream Connection: Upgrade Upgrade: tcp [STREAM] ``` ### Stream format When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate), the HTTP Content-Type header is set to application/vnd.docker.multiplexed-stream and the stream over the hijacked connected is multiplexed to separate out `stdout` and `stderr`. The stream consists of a series of frames, each containing a header and a payload. The header contains the information which the stream writes (`stdout` or `stderr`). It also contains the size of the associated frame encoded in the last four bytes (`uint32`). It is encoded on the first eight bytes like this: ```go header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} ``` `STREAM_TYPE` can be: - 0: `stdin` (is written on `stdout`) - 1: `stdout` - 2: `stderr` `SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the `uint32` size encoded as big endian. Following the header is the payload, which is the specified number of bytes of `STREAM_TYPE`. The simplest way to implement this protocol is the following: 1. Read 8 bytes. 2. Choose `stdout` or `stderr` depending on the first byte. 3. Extract the frame size from the last four bytes. 4. Read the extracted size and output it on the correct output. 5. Goto 1. ### Stream format when using a TTY When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate), the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client\'s `stdin`. * Attach to a container * @param id ID or name of the container - * @param detachKeys Override the key sequence for detaching a container.Format is a single character '[a-Z]' or 'ctrl-<value>' where '<value>' is one of: 'a-z', '@', '^', '[', ',' or '_'. - * @param logs Replay previous logs from the container. This is useful for attaching to a container that has started and you want to output everything since the container started. If 'stream' is also enabled, once all the previous output has been returned, it will seamlessly transition into streaming current output. - * @param stream Stream attached streams from the time the request was made onwards. - * @param stdin Attach to 'stdin' - * @param stdout Attach to 'stdout' - * @param stderr Attach to 'stderr' + * @param stdout + * @param stderr + * @param options + * @param options.detachKeys Override the key sequence for detaching a container.Format is a single character '[a-Z]' or 'ctrl-<value>' where '<value>' is one of: 'a-z', '@', '^', '[', ',' or '_'. + * @param options.logs Replay previous logs from the container. This is useful for attaching to a container that has started and you want to output everything since the container started. If 'stream' is also enabled, once all the previous output has been returned, it will seamlessly transition into streaming current output. + * @param options.stream Stream attached streams from the time the request was made onwards. + * @param options.stdin Attach to 'stdin' + * @param options.stdout Attach to 'stdout' + * @param options.stderr Attach to 'stderr' */ public async containerAttach( id: string, @@ -409,9 +417,9 @@ export class DockerClient { .then((response) => { const contentType = response.headers['content-type']; if (contentType === 'application/vnd.docker.raw-stream') { - response.sock.pipe(stdout); + response.sock?.pipe(stdout); } else { - response.sock.pipe(demultiplexStream(stdout, stderr)); + response.sock?.pipe(demultiplexStream(stdout, stderr)); } }); } @@ -432,8 +440,9 @@ export class DockerClient { /** * Create a container * @param spec Container to create - * @param name Assign the specified name to the container. Must match '/?[a-zA-Z0-9][a-zA-Z0-9_.-]+'. - * @param platform Platform in the format 'os[/arch[/variant]]' used for image lookup. When specified, the daemon checks if the requested image is present in the local image cache with the given OS and Architecture, and otherwise returns a '404' status. If the option is not set, the host\'s native OS and Architecture are used to look up the image in the image cache. However, if no platform is passed and the given image does exist in the local image cache, but its OS or architecture does not match, the container is created with the available image, and a warning is added to the 'Warnings' field in the response, for example; WARNING: The requested image\'s platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested + * @param options + * @param options.name Assign the specified name to the container. Must match '/?[a-zA-Z0-9][a-zA-Z0-9_.-]+'. + * @param options.platform Platform in the format 'os[/arch[/variant]]' used for image lookup. When specified, the daemon checks if the requested image is present in the local image cache with the given OS and Architecture, and otherwise returns a '404' status. If the option is not set, the host\'s native OS and Architecture are used to look up the image in the image cache. However, if no platform is passed and the given image does exist in the local image cache, but its OS or architecture does not match, the container is created with the available image, and a warning is added to the 'Warnings' field in the response, for example; WARNING: The requested image\'s platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested */ public async containerCreate( spec: models.ContainerCreateRequest, @@ -452,9 +461,10 @@ export class DockerClient { /** * Remove a container * @param id ID or name of the container - * @param volumes Remove anonymous volumes associated with the container. - * @param force If the container is running, kill it before removing it. - * @param link Remove the specified link associated with the container. + * @param options + * @param options.volumes Remove anonymous volumes associated with the container. + * @param options.force If the container is running, kill it before removing it. + * @param options.link Remove the specified link associated with the container. */ public async containerDelete( id: string, @@ -474,7 +484,8 @@ export class DockerClient { /** * Export the contents of a container as a tarball. * Export a container - * @param id ID or name of the container + * @param options + * @param options.id ID or name of the container */ public async containerExport(options?: { id: string }): Promise { // TODO @@ -484,7 +495,8 @@ export class DockerClient { * Return low-level information about a container. * Inspect a container * @param id ID or name of the container - * @param size Return the size of container as fields 'SizeRw' and 'SizeRootFs' + * @param options + * @param options.size Return the size of container as fields 'SizeRw' and 'SizeRootFs' */ public async containerInspect( id: string, @@ -502,7 +514,8 @@ export class DockerClient { * Send a POSIX signal to a container, defaulting to killing to the container. * Kill a container * @param id ID or name of the container - * @param signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). + * @param options + * @param options.signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). */ public async containerKill( id: string, @@ -516,10 +529,11 @@ export class DockerClient { /** * Returns a list of containers. For details on the format, see the [inspect endpoint](#operation/ContainerInspect). Note that it uses a different, smaller representation of a container than inspecting a single container. For example, the list of linked containers is not propagated . * List containers - * @param all Return all containers. By default, only running containers are shown. - * @param limit Return this number of most recently created containers, including non-running ones. - * @param size Return the size of container as fields 'SizeRw' and 'SizeRootFs'. - * @param filters Filters to process on the container list, encoded as JSON (a 'map[string][]string'). For example, '{\"status\": [\"paused\"]}' will only return paused containers. Available filters: - 'ancestor''('<image-name>[:<tag>]', '<image id>', or '<image@digest>') - 'before''('<container id>' or '<container name>') - 'expose''('<port>[/<proto>]'|'<startport-endport>/[<proto>]') - 'exited'<int>' containers with exit code of '<int>' - 'health''('starting'|'healthy'|'unhealthy'|'none') - 'id'<ID>' a container\'s ID - 'isolation''('default'|'process'|'hyperv') (Windows daemon only) - 'is-task''('true'|'false') - 'label'key' or 'label'\"key'value\"' of a container label - 'name'<name>' a container\'s name - 'network''('<network id>' or '<network name>') - 'publish''('<port>[/<proto>]'|'<startport-endport>/[<proto>]') - 'since''('<container id>' or '<container name>') - 'status''('created'|'restarting'|'running'|'removing'|'paused'|'exited'|'dead') - 'volume''('<volume name>' or '<mount point destination>') + * @param options + * @param options.all Return all containers. By default, only running containers are shown. + * @param options.limit Return this number of most recently created containers, including non-running ones. + * @param options.size Return the size of container as fields 'SizeRw' and 'SizeRootFs'. + * @param options.filters Filters to process on the container list, encoded as JSON (a 'map[string][]string'). For example, '{\"status\": [\"paused\"]}' will only return paused containers. Available filters: - 'ancestor''('<image-name>[:<tag>]', '<image id>', or '<image@digest>') - 'before''('<container id>' or '<container name>') - 'expose''('<port>[/<proto>]'|'<startport-endport>/[<proto>]') - 'exited'<int>' containers with exit code of '<int>' - 'health''('starting'|'healthy'|'unhealthy'|'none') - 'id'<ID>' a container\'s ID - 'isolation''('default'|'process'|'hyperv') (Windows daemon only) - 'is-task''('true'|'false') - 'label'key' or 'label'\"key'value\"' of a container label - 'name'<name>' a container\'s name - 'network''('<network id>' or '<network name>') - 'publish''('<port>[/<proto>]'|'<startport-endport>/[<proto>]') - 'since''('<container id>' or '<container name>') - 'status''('created'|'restarting'|'running'|'removing'|'paused'|'exited'|'dead') - 'volume''('<volume name>' or '<mount point destination>') */ public async containerList(options?: { all?: boolean; @@ -537,13 +551,16 @@ export class DockerClient { * Get `stdout` and `stderr` logs from a container. Note: This endpoint works only for containers with the `json-file` or `journald` logging driver. * Get container logs * @param id ID or name of the container - * @param follow Keep connection after returning logs. - * @param stdout Return logs from 'stdout' - * @param stderr Return logs from 'stderr' - * @param since Only return logs since this time, as a UNIX timestamp - * @param until Only return logs before this time, as a UNIX timestamp - * @param timestamps Add timestamps to every log line - * @param tail Only return this number of log lines from the end of the logs. Specify as an integer or 'all' to output all log lines. + * @param stdout + * @param stderr + * @param options + * @param options.follow Keep connection after returning logs. + * @param options.stdout Return logs from 'stdout' + * @param options.stderr Return logs from 'stderr' + * @param options.since Only return logs since this time, as a UNIX timestamp + * @param options.until Only return logs before this time, as a UNIX timestamp + * @param options.timestamps Add timestamps to every log line + * @param options.tail Only return this number of log lines from the end of the logs. Specify as an integer or 'all' to output all log lines. */ public async containerLogs( id: string, @@ -579,7 +596,8 @@ export class DockerClient { /** * Delete stopped containers - * @param filters Filters to process on the prune list, encoded as JSON (a 'map[string][]string'). Available filters: - 'until'<timestamp>' Prune containers created before this timestamp. The '<timestamp>' can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. '10m', '1h30m') computed relative to the daemon machine’s time. - 'label' ('label'<key>', 'label'<key>'<value>', 'label!'<key>', or 'label!'<key>'<value>') Prune containers with (or without, in case 'label!'...' is used) the specified labels. + * @param options + * @param options.filters Filters to process on the prune list, encoded as JSON (a 'map[string][]string'). Available filters: - 'until'<timestamp>' Prune containers created before this timestamp. The '<timestamp>' can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. '10m', '1h30m') computed relative to the daemon machine’s time. - 'label' ('label'<key>', 'label'<key>'<value>', 'label!'<key>', or 'label!'<key>'<value>') Prune containers with (or without, in case 'label!'...' is used) the specified labels. */ public async containerPrune(options?: { filters?: string; @@ -603,8 +621,8 @@ export class DockerClient { * Resize the TTY for a container. * Resize a container TTY * @param id ID or name of the container - * @param h Height of the TTY session in characters - * @param w Width of the TTY session in characters + * @param height Height of the TTY session in characters + * @param width Width of the TTY session in characters */ public async containerResize( id: string, @@ -620,8 +638,9 @@ export class DockerClient { /** * Restart a container * @param id ID or name of the container - * @param signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). - * @param t Number of seconds to wait before killing the container + * @param options + * @param options.signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). + * @param options.timeout Number of seconds to wait before killing the container */ public async containerRestart( id: string, @@ -639,7 +658,8 @@ export class DockerClient { /** * Start a container * @param id ID or name of the container - * @param detachKeys Override the key sequence for detaching a container. Format is a single character '[a-Z]' or 'ctrl-<value>' where '<value>' is one of: 'a-z', '@', '^', '[', ',' or '_'. + * @param options + * @param options.detachKeys Override the key sequence for detaching a container. Format is a single character '[a-Z]' or 'ctrl-<value>' where '<value>' is one of: 'a-z', '@', '^', '[', ',' or '_'. */ public async containerStart( id: string, @@ -654,8 +674,9 @@ export class DockerClient { * This endpoint returns a live stream of a container’s resource usage statistics. The `precpu_stats` is the CPU statistic of the *previous* read, and is used to calculate the CPU usage percentage. It is not an exact copy of the `cpu_stats` field. If either `precpu_stats.online_cpus` or `cpu_stats.online_cpus` is nil then for compatibility with older daemons the length of the corresponding `cpu_usage.percpu_usage` array should be used. On a cgroup v2 host, the following fields are not set * `blkio_stats`: all fields other than `io_service_bytes_recursive` * `cpu_stats`: `cpu_usage.percpu_usage` * `memory_stats`: `max_usage` and `failcnt` Also, `memory_stats.stats` fields are incompatible with cgroup v1. To calculate the values shown by the `stats` command of the docker cli tool the following formulas can be used: * used_memory = `memory_stats.usage - memory_stats.stats.cache` * available_memory = `memory_stats.limit` * Memory usage % = `(used_memory / available_memory) * 100.0` * cpu_delta = `cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage` * system_cpu_delta = `cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage` * number_cpus = `length(cpu_stats.cpu_usage.percpu_usage)` or `cpu_stats.online_cpus` * CPU usage % = `(cpu_delta / system_cpu_delta) * number_cpus * 100.0` * Get container stats based on resource usage * @param id ID or name of the container - * @param stream Stream the output. If false, the stats will be output once and then it will disconnect. - * @param oneShot Only get a single stat instead of waiting for 2 cycles. Must be used with 'stream'false'. + * @param options + * @param options.stream Stream the output. If false, the stats will be output once and then it will disconnect. + * @param options.oneShot Only get a single stat instead of waiting for 2 cycles. Must be used with 'stream'false'. */ public async containerStats( id: string, @@ -676,8 +697,9 @@ export class DockerClient { /** * Stop a container * @param id ID or name of the container - * @param signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). - * @param t Number of seconds to wait before killing the container + * @param options + * @param options.signal Signal to send to the container as an integer or string (e.g. 'SIGINT'). + * @param options.timeout Number of seconds to wait before killing the container */ public async containerStop( id: string, @@ -696,7 +718,8 @@ export class DockerClient { * On Unix systems, this is done by running the `ps` command. This endpoint is not supported on Windows. * List processes running inside a container * @param id ID or name of the container - * @param psArgs The arguments to pass to 'ps'. For example, 'aux' + * @param options + * @param options.psArgs The arguments to pass to 'ps'. For example, 'aux' */ public async containerTop( id: string, @@ -741,7 +764,8 @@ export class DockerClient { * Block until a container stops, then returns the exit code. * Wait for a container * @param id ID or name of the container - * @param condition Wait until a container state reaches the given condition. Defaults to 'not-running' if omitted or empty. + * @param options + * @param options.condition Wait until a container state reaches the given condition. Defaults to 'not-running' if omitted or empty. */ public async containerWait( id: string, @@ -762,8 +786,9 @@ export class DockerClient { * @param id ID or name of the container * @param path Path to a directory in the container to extract the archive’s contents into. * @param tar The input stream must be a tar archive compressed with one of the following algorithms: 'identity' (no compression), 'gzip', 'bzip2', or 'xz'. - * @param noOverwriteDirNonDir If '1', 'true', or 'True' then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa. - * @param copyUIDGID If '1', 'true', then it will copy UID/GID maps to the dest file or dir + * @param options + * @param options.noOverwriteDirNonDir If '1', 'true', or 'True' then it will be an error if unpacking the given content would cause an existing directory to be replaced with a non-directory and vice versa. + * @param options.copyUIDGID If '1', 'true', then it will copy UID/GID maps to the dest file or dir */ public async putContainerArchive( id: string, @@ -803,7 +828,7 @@ export class DockerClient { /** * Create a network - * @param networkConfig Network configuration + * @param config Network configuration */ public async networkCreate( config: models.NetworkCreateRequest, @@ -834,8 +859,9 @@ export class DockerClient { /** * Inspect a network * @param id Network ID or name - * @param verbose Detailed inspect output for troubleshooting - * @param scope Filter the network by scope (swarm, global, or local) + * @param options + * @param options.verbose Detailed inspect output for troubleshooting + * @param options.scope Filter the network by scope (swarm, global, or local) */ public async networkInspect( id: string, @@ -850,7 +876,8 @@ export class DockerClient { /** * Returns a list of networks. For details on the format, see the [network inspect endpoint](#operation/NetworkInspect). Note that it uses a different, smaller representation of a network than inspecting a single network. For example, the list of containers attached to the network is not propagated in API versions 1.28 and up. * List networks - * @param filters JSON encoded value of the filters (a 'map[string][]string') to process on the networks list. Available filters: - 'dangling'<boolean>' When set to 'true' (or '1'), returns all networks that are not in use by a container. When set to 'false' (or '0'), only networks that are in use by one or more containers are returned. - 'driver'<driver-name>' Matches a network\'s driver. - 'id'<network-id>' Matches all or part of a network ID. - 'label'<key>' or 'label'<key>'<value>' of a network label. - 'name'<network-name>' Matches all or part of a network name. - 'scope'[\"swarm\"|\"global\"|\"local\"]' Filters networks by scope ('swarm', 'global', or 'local'). - 'type'[\"custom\"|\"builtin\"]' Filters networks by type. The 'custom' keyword returns all user-defined networks. + * @param options + * @param options.filters JSON encoded value of the filters (a 'map[string][]string') to process on the networks list. Available filters: - 'dangling'<boolean>' When set to 'true' (or '1'), returns all networks that are not in use by a container. When set to 'false' (or '0'), only networks that are in use by one or more containers are returned. - 'driver'<driver-name>' Matches a network\'s driver. - 'id'<network-id>' Matches all or part of a network ID. - 'label'<key>' or 'label'<key>'<value>' of a network label. - 'name'<network-name>' Matches all or part of a network name. - 'scope'[\"swarm\"|\"global\"|\"local\"]' Filters networks by scope ('swarm', 'global', or 'local'). - 'type'[\"custom\"|\"builtin\"]' Filters networks by type. The 'custom' keyword returns all user-defined networks. */ public async networkList(options?: { filters?: Filter; @@ -872,7 +899,7 @@ export class DockerClient { /** * Create a volume - * @param volumeConfig Volume configuration + * @param spec Volume configuration */ public async volumeCreate( spec: models.VolumeCreateOptions, @@ -884,7 +911,8 @@ export class DockerClient { * Instruct the driver to remove the volume. * Remove a volume * @param id Volume name or ID - * @param force Force the removal of the volume + * @param options + * @param options.force Force the removal of the volume */ public async volumeDelete( id: string, @@ -897,7 +925,7 @@ export class DockerClient { /** * Inspect a volume - * @param name Volume name or ID + * @param id Volume name or ID */ public async volumeInspect(id: string): Promise { return this.api.get(`/volumes/${id}`); @@ -943,15 +971,17 @@ export class DockerClient { /** * Pull or import an image. * Create an image - * @param fromImage Name of the image to pull. If the name includes a tag or digest, specific behavior applies: - If only 'fromImage' includes a tag, that tag is used. - If both 'fromImage' and 'tag' are provided, 'tag' takes precedence. - If 'fromImage' includes a digest, the image is pulled by digest, and 'tag' is ignored. - If neither a tag nor digest is specified, all tags are pulled. - * @param fromSrc Source to import. The value may be a URL from which the image can be retrieved or '-' to read the image from the request body. This parameter may only be used when importing an image. - * @param repo Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image. - * @param tag Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled. - * @param message Set commit message for imported image. - * @param credentials A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details. - * @param changes Apply 'Dockerfile' instructions to the image that is created, for example: 'changes'ENV DEBUG'true'. Note that 'ENV DEBUG'true' should be URI component encoded. Supported 'Dockerfile' instructions: 'CMD'|'ENTRYPOINT'|'ENV'|'EXPOSE'|'ONBUILD'|'USER'|'VOLUME'|'WORKDIR' - * @param platform Platform in the format os[/arch[/variant]]. When used in combination with the 'fromImage' option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host\'s native OS and Architecture are used. If the given image does not exist in the local image cache, the daemon attempts to pull the image with the host\'s native OS and Architecture. If the given image does exists in the local image cache, but its OS or architecture does not match, a warning is produced. When used with the 'fromSrc' option to import an image from an archive, this option sets the platform information for the imported image. If the option is not set, the host\'s native OS and Architecture are used for the imported image. - * @param inputImage Image content if the value '-' has been specified in fromSrc query parameter + * @param callback + * @param options + * @param options.fromImage Name of the image to pull. If the name includes a tag or digest, specific behavior applies: - If only 'fromImage' includes a tag, that tag is used. - If both 'fromImage' and 'tag' are provided, 'tag' takes precedence. - If 'fromImage' includes a digest, the image is pulled by digest, and 'tag' is ignored. - If neither a tag nor digest is specified, all tags are pulled. + * @param options.fromSrc Source to import. The value may be a URL from which the image can be retrieved or '-' to read the image from the request body. This parameter may only be used when importing an image. + * @param options.repo Repository name given to an image when it is imported. The repo may include a tag. This parameter may only be used when importing an image. + * @param options.tag Tag or digest. If empty when pulling an image, this causes all tags for the given image to be pulled. + * @param options.message Set commit message for imported image. + * @param options.credentials A base64url-encoded auth configuration. Refer to the [authentication section](#section/Authentication) for details. + * @param options.changes Apply 'Dockerfile' instructions to the image that is created, for example: 'changes'ENV DEBUG'true'. Note that 'ENV DEBUG'true' should be URI component encoded. Supported 'Dockerfile' instructions: 'CMD'|'ENTRYPOINT'|'ENV'|'EXPOSE'|'ONBUILD'|'USER'|'VOLUME'|'WORKDIR' + * @param options.platform Platform in the format os[/arch[/variant]]. When used in combination with the 'fromImage' option, the daemon checks if the given image is present in the local image cache with the given OS and Architecture, and otherwise attempts to pull the image. If the option is not set, the host\'s native OS and Architecture are used. If the given image does not exist in the local image cache, the daemon attempts to pull the image with the host\'s native OS and Architecture. If the given image does exists in the local image cache, but its OS or architecture does not match, a warning is produced. When used with the 'fromSrc' option to import an image from an archive, this option sets the platform information for the imported image. If the option is not set, the host\'s native OS and Architecture are used for the imported image. + * @param options.inputImage Image content if the value '-' has been specified in fromSrc query parameter */ public async imageCreate( callback: (event: any) => void, @@ -1003,9 +1033,10 @@ export class DockerClient { * Remove an image, along with any untagged parent images that were referenced by that image. Images can\'t be removed if they have descendant images, are being used by a running container or are being used by a build. * Remove an image * @param name Image name or ID - * @param force Remove the image even if it is being used by stopped containers or has other tags - * @param noprune Do not delete untagged parent images - * @param platforms Select platform-specific content to delete. Multiple values are accepted. Each platform is a OCI platform encoded as a JSON string. + * @param options + * @param options.force Remove the image even if it is being used by stopped containers or has other tags + * @param options.noprune Do not delete untagged parent images + * @param options.platforms Select platform-specific content to delete. Multiple values are accepted. Each platform is a OCI platform encoded as a JSON string. */ public async imageDelete( name: string, @@ -1022,7 +1053,8 @@ export class DockerClient { * Return parent layers of an image. * Get the history of an image * @param name Image name or ID - * @param platform JSON-encoded OCI platform to select the platform-variant. If omitted, it defaults to any locally available platform, prioritizing the daemon\'s host platform. If the daemon provides a multi-platform image store, this selects the platform-variant to show the history for. If the image is a single-platform image, or if the multi-platform image does not provide a variant matching the given platform, an error is returned. Example: '{\"os\": \"linux\", \"architecture\": \"arm\", \"variant\": \"v5\"}' + * @param options + * @param options.platform JSON-encoded OCI platform to select the platform-variant. If omitted, it defaults to any locally available platform, prioritizing the daemon\'s host platform. If the daemon provides a multi-platform image store, this selects the platform-variant to show the history for. If the image is a single-platform image, or if the multi-platform image does not provide a variant matching the given platform, an error is returned. Example: '{\"os\": \"linux\", \"architecture\": \"arm\", \"variant\": \"v5\"}' */ public async imageHistory( name: string, @@ -1037,7 +1069,8 @@ export class DockerClient { * Return low-level information about an image. * Inspect an image * @param name Image name or id - * @param manifests Include Manifests in the image summary. + * @param options + * @param options.manifests Include Manifests in the image summary. */ public async imageInspect( name: string, @@ -1051,11 +1084,12 @@ export class DockerClient { /** * Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image. * List Images - * @param all Show all images. Only images from a final layer (no children) are shown by default. - * @param filters A JSON encoded value of the filters (a 'map[string][]string') to process on the images list. Available filters: - 'before''('<image-name>[:<tag>]', '<image id>' or '<image@digest>') - 'dangling'true' - 'label'key' or 'label'\"key'value\"' of an image label - 'reference''('<image-name>[:<tag>]') - 'since''('<image-name>[:<tag>]', '<image id>' or '<image@digest>') - 'until'<timestamp>' - * @param sharedSize Compute and show shared size as a 'SharedSize' field on each image. - * @param digests Show digest information as a 'RepoDigests' field on each image. - * @param manifests Include 'Manifests' in the image summary. + * @param options + * @param options.all Show all images. Only images from a final layer (no children) are shown by default. + * @param options.filters A JSON encoded value of the filters (a 'map[string][]string') to process on the images list. Available filters: - 'before''('<image-name>[:<tag>]', '<image id>' or '<image@digest>') - 'dangling'true' - 'label'key' or 'label'\"key'value\"' of an image label - 'reference''('<image-name>[:<tag>]') - 'since''('<image-name>[:<tag>]', '<image id>' or '<image@digest>') - 'until'<timestamp>' + * @param options.sharedSize Compute and show shared size as a 'SharedSize' field on each image. + * @param options.digests Show digest information as a 'RepoDigests' field on each image. + * @param options.manifests Include 'Manifests' in the image summary. */ public async imageList(options?: { all?: boolean; @@ -1095,8 +1129,8 @@ export class DockerClient { * Resize the TTY session used b * Resize an exec instance * @param id Exec instance ID - * @param h Height of the TTY se - * @param w Width of the TTY ses + * @param height Height of the TTY se + * @param width Width of the TTY ses */ public async execResize( id: string, diff --git a/lib/http.ts b/lib/http.ts index ff90d56..6577f5f 100644 --- a/lib/http.ts +++ b/lib/http.ts @@ -1,6 +1,6 @@ -import * as net from 'net'; import * as http from 'http'; import * as stream from 'stream'; +import { getErrorMessage } from './util.js'; // Docker stream content type constants const DOCKER_RAW_STREAM = 'application/vnd.docker.raw-stream'; @@ -31,10 +31,10 @@ export class ConflictError extends Error { } // Function to extract error message from response body -function getErrorMessage( +function getErrorMessageFromResp( res: http.IncomingMessage, body: string | undefined, -): string { +): string | undefined { const contentType = res.headers['content-type']?.toLowerCase(); if (contentType?.includes('application/json') && body) { const jsonBody = JSON.parse(body); @@ -47,8 +47,8 @@ function getErrorMessage( // Interface to represent an HTTP response export interface HTTPResponse { - statusMessage: string; - statusCode: number; + statusMessage?: string; + statusCode?: number; headers: { [key: string]: string }; body?: string; sock?: stream.Duplex; @@ -160,8 +160,9 @@ export class HTTPClient { const handleResponseEnd = (body?: string) => { const response = createResponse(res, body); - if (res.statusCode >= 400) { - const errorMessage = getErrorMessage(res, body); + if (res.statusCode && res.statusCode >= 400) { + const errorMessage = + getErrorMessageFromResp(res, body) ?? ''; if (res.statusCode === 404) { reject(new NotFoundError(errorMessage)); } else if (res.statusCode === 401) { @@ -179,7 +180,9 @@ export class HTTPClient { // Helper function to handle response errors const handleResponseError = (error: Error) => { reject( - new Error(`Response stream error: ${error.message}`), + new Error( + `Response stream error: ${getErrorMessage(error)}`, + ), ); }; diff --git a/lib/models/BuildInfo.ts b/lib/models/BuildInfo.ts index 6d35b56..25b2097 100644 --- a/lib/models/BuildInfo.ts +++ b/lib/models/BuildInfo.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ErrorDetail } from '../models/ErrorDetail.js'; -import { ImageID } from '../models/ImageID.js'; -import { ProgressDetail } from '../models/ProgressDetail.js'; +import { type ErrorDetail } from '../models/ErrorDetail.js'; +import { type ImageID } from '../models/ImageID.js'; +import { type ProgressDetail } from '../models/ProgressDetail.js'; export interface BuildInfo { Id?: string; diff --git a/lib/models/ClusterInfo.ts b/lib/models/ClusterInfo.ts index f42ea44..9be9c0c 100644 --- a/lib/models/ClusterInfo.ts +++ b/lib/models/ClusterInfo.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ObjectVersion } from '../models/ObjectVersion.js'; -import { SwarmSpec } from '../models/SwarmSpec.js'; -import { TLSInfo } from '../models/TLSInfo.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; +import { type SwarmSpec } from '../models/SwarmSpec.js'; +import { type TLSInfo } from '../models/TLSInfo.js'; /** * ClusterInfo represents information about the swarm as is returned by the \"/info\" endpoint. Join-tokens are not included. diff --git a/lib/models/ClusterVolume.ts b/lib/models/ClusterVolume.ts index e3a8d06..5ab4b7c 100644 --- a/lib/models/ClusterVolume.ts +++ b/lib/models/ClusterVolume.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { ClusterVolumeInfo } from '../models/ClusterVolumeInfo.js'; -import { ClusterVolumePublishStatusInner } from '../models/ClusterVolumePublishStatusInner.js'; -import { ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; -import { ObjectVersion } from '../models/ObjectVersion.js'; +import { type ClusterVolumeInfo } from '../models/ClusterVolumeInfo.js'; +import { type ClusterVolumePublishStatusInner } from '../models/ClusterVolumePublishStatusInner.js'; +import { type ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; /** * Options and information specific to, and only present on, Swarm CSI cluster volumes. diff --git a/lib/models/ClusterVolumeSpec.ts b/lib/models/ClusterVolumeSpec.ts index 6b8d2d8..f045d1c 100644 --- a/lib/models/ClusterVolumeSpec.ts +++ b/lib/models/ClusterVolumeSpec.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ClusterVolumeSpecAccessMode } from '../models/ClusterVolumeSpecAccessMode.js'; +import { type ClusterVolumeSpecAccessMode } from '../models/ClusterVolumeSpecAccessMode.js'; /** * Cluster-specific options used to create the volume. diff --git a/lib/models/ClusterVolumeSpecAccessMode.ts b/lib/models/ClusterVolumeSpecAccessMode.ts index 5ec44cf..8b9c9c3 100644 --- a/lib/models/ClusterVolumeSpecAccessMode.ts +++ b/lib/models/ClusterVolumeSpecAccessMode.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ClusterVolumeSpecAccessModeAccessibilityRequirements } from '../models/ClusterVolumeSpecAccessModeAccessibilityRequirements.js'; -import { ClusterVolumeSpecAccessModeCapacityRange } from '../models/ClusterVolumeSpecAccessModeCapacityRange.js'; -import { ClusterVolumeSpecAccessModeSecretsInner } from '../models/ClusterVolumeSpecAccessModeSecretsInner.js'; +import { type ClusterVolumeSpecAccessModeAccessibilityRequirements } from '../models/ClusterVolumeSpecAccessModeAccessibilityRequirements.js'; +import { type ClusterVolumeSpecAccessModeCapacityRange } from '../models/ClusterVolumeSpecAccessModeCapacityRange.js'; +import { type ClusterVolumeSpecAccessModeSecretsInner } from '../models/ClusterVolumeSpecAccessModeSecretsInner.js'; /** * Defines how the volume is used by tasks. diff --git a/lib/models/Config.ts b/lib/models/Config.ts index 94328c7..17661dc 100644 --- a/lib/models/Config.ts +++ b/lib/models/Config.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ConfigSpec } from '../models/ConfigSpec.js'; -import { ObjectVersion } from '../models/ObjectVersion.js'; +import { type ConfigSpec } from '../models/ConfigSpec.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; export interface Config { ID?: string; diff --git a/lib/models/ConfigCreateRequest.ts b/lib/models/ConfigCreateRequest.ts index 691b4e3..eb4175a 100644 --- a/lib/models/ConfigCreateRequest.ts +++ b/lib/models/ConfigCreateRequest.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Driver } from '../models/Driver.js'; +import { type Driver } from '../models/Driver.js'; export interface ConfigCreateRequest { /** diff --git a/lib/models/ConfigSpec.ts b/lib/models/ConfigSpec.ts index 9c2c6e3..fc24c1a 100644 --- a/lib/models/ConfigSpec.ts +++ b/lib/models/ConfigSpec.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Driver } from '../models/Driver.js'; +import { type Driver } from '../models/Driver.js'; export interface ConfigSpec { /** diff --git a/lib/models/ContainerBlkioStats.ts b/lib/models/ContainerBlkioStats.ts index 5c28c98..0baa602 100644 --- a/lib/models/ContainerBlkioStats.ts +++ b/lib/models/ContainerBlkioStats.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ContainerBlkioStatEntry } from '../models/ContainerBlkioStatEntry.js'; +import { type ContainerBlkioStatEntry } from '../models/ContainerBlkioStatEntry.js'; /** * BlkioStats stores all IO service stats for data read and write. This type is Linux-specific and holds many fields that are specific to cgroups v1. On a cgroup v2 host, all fields other than `io_service_bytes_recursive` are omitted or `null`. This type is only populated on Linux and omitted for Windows containers. diff --git a/lib/models/ContainerCPUStats.ts b/lib/models/ContainerCPUStats.ts index 3cfa6c3..70dce10 100644 --- a/lib/models/ContainerCPUStats.ts +++ b/lib/models/ContainerCPUStats.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ContainerCPUUsage } from '../models/ContainerCPUUsage.js'; -import { ContainerThrottlingData } from '../models/ContainerThrottlingData.js'; +import { type ContainerCPUUsage } from '../models/ContainerCPUUsage.js'; +import { type ContainerThrottlingData } from '../models/ContainerThrottlingData.js'; /** * CPU related info of the container diff --git a/lib/models/ContainerConfig.ts b/lib/models/ContainerConfig.ts index 2223ab7..999192e 100644 --- a/lib/models/ContainerConfig.ts +++ b/lib/models/ContainerConfig.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { HealthConfig } from '../models/HealthConfig.js'; +import { type HealthConfig } from '../models/HealthConfig.js'; /** * Configuration for a container that is portable between hosts. diff --git a/lib/models/ContainerCreateRequest.ts b/lib/models/ContainerCreateRequest.ts index 391cb9a..229aaa1 100644 --- a/lib/models/ContainerCreateRequest.ts +++ b/lib/models/ContainerCreateRequest.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { HealthConfig } from '../models/HealthConfig.js'; -import { HostConfig } from '../models/HostConfig.js'; -import { NetworkingConfig } from '../models/NetworkingConfig.js'; +import { type HealthConfig } from '../models/HealthConfig.js'; +import { type HostConfig } from '../models/HostConfig.js'; +import { type NetworkingConfig } from '../models/NetworkingConfig.js'; export interface ContainerCreateRequest { /** diff --git a/lib/models/ContainerInspectResponse.ts b/lib/models/ContainerInspectResponse.ts index b8abe06..7152150 100644 --- a/lib/models/ContainerInspectResponse.ts +++ b/lib/models/ContainerInspectResponse.ts @@ -18,13 +18,13 @@ Do not edit the class manually. */ -import { ContainerConfig } from '../models/ContainerConfig.js'; -import { ContainerState } from '../models/ContainerState.js'; -import { DriverData } from '../models/DriverData.js'; -import { HostConfig } from '../models/HostConfig.js'; -import { MountPoint } from '../models/MountPoint.js'; -import { NetworkSettings } from '../models/NetworkSettings.js'; -import { OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type ContainerConfig } from '../models/ContainerConfig.js'; +import { type ContainerState } from '../models/ContainerState.js'; +import { type DriverData } from '../models/DriverData.js'; +import { type HostConfig } from '../models/HostConfig.js'; +import { type MountPoint } from '../models/MountPoint.js'; +import { type NetworkSettings } from '../models/NetworkSettings.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; export interface ContainerInspectResponse { /** diff --git a/lib/models/ContainerState.ts b/lib/models/ContainerState.ts index 4957bda..dc0d9e2 100644 --- a/lib/models/ContainerState.ts +++ b/lib/models/ContainerState.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Health } from '../models/Health.js'; +import { type Health } from '../models/Health.js'; /** * ContainerState stores container\'s running state. It\'s part of ContainerJSONBase and will be returned by the \"inspect\" command. diff --git a/lib/models/ContainerStatsResponse.ts b/lib/models/ContainerStatsResponse.ts index ff97da9..6150300 100644 --- a/lib/models/ContainerStatsResponse.ts +++ b/lib/models/ContainerStatsResponse.ts @@ -18,11 +18,11 @@ Do not edit the class manually. */ -import { ContainerBlkioStats } from '../models/ContainerBlkioStats.js'; -import { ContainerCPUStats } from '../models/ContainerCPUStats.js'; -import { ContainerMemoryStats } from '../models/ContainerMemoryStats.js'; -import { ContainerPidsStats } from '../models/ContainerPidsStats.js'; -import { ContainerStorageStats } from '../models/ContainerStorageStats.js'; +import { type ContainerBlkioStats } from '../models/ContainerBlkioStats.js'; +import { type ContainerCPUStats } from '../models/ContainerCPUStats.js'; +import { type ContainerMemoryStats } from '../models/ContainerMemoryStats.js'; +import { type ContainerPidsStats } from '../models/ContainerPidsStats.js'; +import { type ContainerStorageStats } from '../models/ContainerStorageStats.js'; /** * Statistics sample for a container. diff --git a/lib/models/ContainerSummary.ts b/lib/models/ContainerSummary.ts index 7d9d0d4..51b15cc 100644 --- a/lib/models/ContainerSummary.ts +++ b/lib/models/ContainerSummary.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { ContainerSummaryHealth } from '../models/ContainerSummaryHealth.js'; -import { ContainerSummaryHostConfig } from '../models/ContainerSummaryHostConfig.js'; -import { ContainerSummaryNetworkSettings } from '../models/ContainerSummaryNetworkSettings.js'; -import { MountPoint } from '../models/MountPoint.js'; -import { OCIDescriptor } from '../models/OCIDescriptor.js'; -import { PortSummary } from '../models/PortSummary.js'; +import { type ContainerSummaryHealth } from '../models/ContainerSummaryHealth.js'; +import { type ContainerSummaryHostConfig } from '../models/ContainerSummaryHostConfig.js'; +import { type ContainerSummaryNetworkSettings } from '../models/ContainerSummaryNetworkSettings.js'; +import { type MountPoint } from '../models/MountPoint.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type PortSummary } from '../models/PortSummary.js'; export interface ContainerSummary { /** diff --git a/lib/models/ContainerSummaryNetworkSettings.ts b/lib/models/ContainerSummaryNetworkSettings.ts index e5c795f..df8cf71 100644 --- a/lib/models/ContainerSummaryNetworkSettings.ts +++ b/lib/models/ContainerSummaryNetworkSettings.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointSettings } from '../models/EndpointSettings.js'; +import { type EndpointSettings } from '../models/EndpointSettings.js'; /** * Summary of the container\'s network settings diff --git a/lib/models/ContainerUpdateRequest.ts b/lib/models/ContainerUpdateRequest.ts index 5425ee8..d94fe23 100644 --- a/lib/models/ContainerUpdateRequest.ts +++ b/lib/models/ContainerUpdateRequest.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { DeviceMapping } from '../models/DeviceMapping.js'; -import { DeviceRequest } from '../models/DeviceRequest.js'; -import { ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; -import { ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; -import { RestartPolicy } from '../models/RestartPolicy.js'; -import { ThrottleDevice } from '../models/ThrottleDevice.js'; +import { type DeviceMapping } from '../models/DeviceMapping.js'; +import { type DeviceRequest } from '../models/DeviceRequest.js'; +import { type ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; +import { type ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; +import { type RestartPolicy } from '../models/RestartPolicy.js'; +import { type ThrottleDevice } from '../models/ThrottleDevice.js'; export interface ContainerUpdateRequest { /** diff --git a/lib/models/ContainerWaitResponse.ts b/lib/models/ContainerWaitResponse.ts index 89469ca..7a59415 100644 --- a/lib/models/ContainerWaitResponse.ts +++ b/lib/models/ContainerWaitResponse.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ContainerWaitExitError } from '../models/ContainerWaitExitError.js'; +import { type ContainerWaitExitError } from '../models/ContainerWaitExitError.js'; /** * OK response to ContainerWait operation diff --git a/lib/models/ContainerdInfo.ts b/lib/models/ContainerdInfo.ts index f3e4318..8ea0bd8 100644 --- a/lib/models/ContainerdInfo.ts +++ b/lib/models/ContainerdInfo.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ContainerdInfoNamespaces } from '../models/ContainerdInfoNamespaces.js'; +import { type ContainerdInfoNamespaces } from '../models/ContainerdInfoNamespaces.js'; /** * Information for connecting to the containerd instance that is used by the daemon. This is included for debugging purposes only. diff --git a/lib/models/CreateImageInfo.ts b/lib/models/CreateImageInfo.ts index 9e16fe7..a3d0e4b 100644 --- a/lib/models/CreateImageInfo.ts +++ b/lib/models/CreateImageInfo.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ErrorDetail } from '../models/ErrorDetail.js'; -import { ProgressDetail } from '../models/ProgressDetail.js'; +import { type ErrorDetail } from '../models/ErrorDetail.js'; +import { type ProgressDetail } from '../models/ProgressDetail.js'; export interface CreateImageInfo { Id?: string; diff --git a/lib/models/DistributionInspect.ts b/lib/models/DistributionInspect.ts index d505f75..de11354 100644 --- a/lib/models/DistributionInspect.ts +++ b/lib/models/DistributionInspect.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { OCIDescriptor } from '../models/OCIDescriptor.js'; -import { OCIPlatform } from '../models/OCIPlatform.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type OCIPlatform } from '../models/OCIPlatform.js'; /** * Describes the result obtained from contacting the registry to retrieve image metadata. diff --git a/lib/models/EndpointSettings.ts b/lib/models/EndpointSettings.ts index 7c36974..dfe5d78 100644 --- a/lib/models/EndpointSettings.ts +++ b/lib/models/EndpointSettings.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointIPAMConfig } from '../models/EndpointIPAMConfig.js'; +import { type EndpointIPAMConfig } from '../models/EndpointIPAMConfig.js'; /** * Configuration for a network endpoint. diff --git a/lib/models/EndpointSpec.ts b/lib/models/EndpointSpec.ts index 383a409..bae3965 100644 --- a/lib/models/EndpointSpec.ts +++ b/lib/models/EndpointSpec.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointPortConfig } from '../models/EndpointPortConfig.js'; +import { type EndpointPortConfig } from '../models/EndpointPortConfig.js'; /** * Properties that can be configured to access and load balance a service. diff --git a/lib/models/EngineDescription.ts b/lib/models/EngineDescription.ts index cf57b81..aa76f50 100644 --- a/lib/models/EngineDescription.ts +++ b/lib/models/EngineDescription.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EngineDescriptionPluginsInner } from '../models/EngineDescriptionPluginsInner.js'; +import { type EngineDescriptionPluginsInner } from '../models/EngineDescriptionPluginsInner.js'; /** * EngineDescription provides information about an engine. diff --git a/lib/models/EventMessage.ts b/lib/models/EventMessage.ts index 96bd0fe..232de48 100644 --- a/lib/models/EventMessage.ts +++ b/lib/models/EventMessage.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EventActor } from '../models/EventActor.js'; +import { type EventActor } from '../models/EventActor.js'; /** * EventMessage represents the information an event contains. diff --git a/lib/models/ExecInspectResponse.ts b/lib/models/ExecInspectResponse.ts index b32274c..a7b4616 100644 --- a/lib/models/ExecInspectResponse.ts +++ b/lib/models/ExecInspectResponse.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ProcessConfig } from '../models/ProcessConfig.js'; +import { type ProcessConfig } from '../models/ProcessConfig.js'; export interface ExecInspectResponse { CanRemove?: boolean; diff --git a/lib/models/FilesystemChange.ts b/lib/models/FilesystemChange.ts index 4cb9752..0f1caad 100644 --- a/lib/models/FilesystemChange.ts +++ b/lib/models/FilesystemChange.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ChangeType } from '../models/ChangeType.js'; +import { type ChangeType } from '../models/ChangeType.js'; /** * Change in the container\'s filesystem. diff --git a/lib/models/GenericResourcesInner.ts b/lib/models/GenericResourcesInner.ts index f095d0f..7f95079 100644 --- a/lib/models/GenericResourcesInner.ts +++ b/lib/models/GenericResourcesInner.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { GenericResourcesInnerDiscreteResourceSpec } from '../models/GenericResourcesInnerDiscreteResourceSpec.js'; -import { GenericResourcesInnerNamedResourceSpec } from '../models/GenericResourcesInnerNamedResourceSpec.js'; +import { type GenericResourcesInnerDiscreteResourceSpec } from '../models/GenericResourcesInnerDiscreteResourceSpec.js'; +import { type GenericResourcesInnerNamedResourceSpec } from '../models/GenericResourcesInnerNamedResourceSpec.js'; export interface GenericResourcesInner { NamedResourceSpec?: GenericResourcesInnerNamedResourceSpec; diff --git a/lib/models/Health.ts b/lib/models/Health.ts index 440e6c6..a29b03e 100644 --- a/lib/models/Health.ts +++ b/lib/models/Health.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { HealthcheckResult } from '../models/HealthcheckResult.js'; +import { type HealthcheckResult } from '../models/HealthcheckResult.js'; /** * Health stores information about the container\'s healthcheck results. diff --git a/lib/models/HostConfig.ts b/lib/models/HostConfig.ts index 2bd079a..e4a18bb 100644 --- a/lib/models/HostConfig.ts +++ b/lib/models/HostConfig.ts @@ -18,15 +18,15 @@ Do not edit the class manually. */ -import { DeviceMapping } from '../models/DeviceMapping.js'; -import { DeviceRequest } from '../models/DeviceRequest.js'; -import { HostConfigAllOfLogConfig } from '../models/HostConfigAllOfLogConfig.js'; -import { Mount } from '../models/Mount.js'; -import { PortBinding } from '../models/PortBinding.js'; -import { ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; -import { ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; -import { RestartPolicy } from '../models/RestartPolicy.js'; -import { ThrottleDevice } from '../models/ThrottleDevice.js'; +import { type DeviceMapping } from '../models/DeviceMapping.js'; +import { type DeviceRequest } from '../models/DeviceRequest.js'; +import { type HostConfigAllOfLogConfig } from '../models/HostConfigAllOfLogConfig.js'; +import { type Mount } from '../models/Mount.js'; +import { type PortBinding } from '../models/PortBinding.js'; +import { type ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; +import { type ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; +import { type RestartPolicy } from '../models/RestartPolicy.js'; +import { type ThrottleDevice } from '../models/ThrottleDevice.js'; /** * Container configuration that depends on the host we are running on diff --git a/lib/models/IPAM.ts b/lib/models/IPAM.ts index fcfa398..c7ae5f1 100644 --- a/lib/models/IPAM.ts +++ b/lib/models/IPAM.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { IPAMConfig } from '../models/IPAMConfig.js'; +import { type IPAMConfig } from '../models/IPAMConfig.js'; export interface IPAM { /** diff --git a/lib/models/ImageConfig.ts b/lib/models/ImageConfig.ts index 559a117..d20ad3c 100644 --- a/lib/models/ImageConfig.ts +++ b/lib/models/ImageConfig.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { HealthConfig } from '../models/HealthConfig.js'; +import { type HealthConfig } from '../models/HealthConfig.js'; /** * Configuration of the image. These fields are used as defaults when starting a container from the image. diff --git a/lib/models/ImageInspect.ts b/lib/models/ImageInspect.ts index 5858c95..9baedaa 100644 --- a/lib/models/ImageInspect.ts +++ b/lib/models/ImageInspect.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { DriverData } from '../models/DriverData.js'; -import { ImageConfig } from '../models/ImageConfig.js'; -import { ImageInspectMetadata } from '../models/ImageInspectMetadata.js'; -import { ImageInspectRootFS } from '../models/ImageInspectRootFS.js'; -import { ImageManifestSummary } from '../models/ImageManifestSummary.js'; -import { OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type DriverData } from '../models/DriverData.js'; +import { type ImageConfig } from '../models/ImageConfig.js'; +import { type ImageInspectMetadata } from '../models/ImageInspectMetadata.js'; +import { type ImageInspectRootFS } from '../models/ImageInspectRootFS.js'; +import { type ImageManifestSummary } from '../models/ImageManifestSummary.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; /** * Information about an image in the local image cache. diff --git a/lib/models/ImageManifestSummary.ts b/lib/models/ImageManifestSummary.ts index 41ae941..d325d7e 100644 --- a/lib/models/ImageManifestSummary.ts +++ b/lib/models/ImageManifestSummary.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { ImageManifestSummaryAttestationData } from '../models/ImageManifestSummaryAttestationData.js'; -import { ImageManifestSummaryImageData } from '../models/ImageManifestSummaryImageData.js'; -import { ImageManifestSummarySize } from '../models/ImageManifestSummarySize.js'; -import { OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type ImageManifestSummaryAttestationData } from '../models/ImageManifestSummaryAttestationData.js'; +import { type ImageManifestSummaryImageData } from '../models/ImageManifestSummaryImageData.js'; +import { type ImageManifestSummarySize } from '../models/ImageManifestSummarySize.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; /** * ImageManifestSummary represents a summary of an image manifest. diff --git a/lib/models/ImageManifestSummaryImageData.ts b/lib/models/ImageManifestSummaryImageData.ts index c39e1aa..d468792 100644 --- a/lib/models/ImageManifestSummaryImageData.ts +++ b/lib/models/ImageManifestSummaryImageData.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ImageManifestSummaryImageDataSize } from '../models/ImageManifestSummaryImageDataSize.js'; -import { OCIPlatform } from '../models/OCIPlatform.js'; +import { type ImageManifestSummaryImageDataSize } from '../models/ImageManifestSummaryImageDataSize.js'; +import { type OCIPlatform } from '../models/OCIPlatform.js'; /** * The image data for the image manifest. This field is only populated when Kind is \"image\". diff --git a/lib/models/ImagePruneResponse.ts b/lib/models/ImagePruneResponse.ts index 77b439e..336c696 100644 --- a/lib/models/ImagePruneResponse.ts +++ b/lib/models/ImagePruneResponse.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ImageDeleteResponseItem } from '../models/ImageDeleteResponseItem.js'; +import { type ImageDeleteResponseItem } from '../models/ImageDeleteResponseItem.js'; export interface ImagePruneResponse { /** diff --git a/lib/models/ImageSummary.ts b/lib/models/ImageSummary.ts index 87077bc..52fd05d 100644 --- a/lib/models/ImageSummary.ts +++ b/lib/models/ImageSummary.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ImageManifestSummary } from '../models/ImageManifestSummary.js'; -import { OCIDescriptor } from '../models/OCIDescriptor.js'; +import { type ImageManifestSummary } from '../models/ImageManifestSummary.js'; +import { type OCIDescriptor } from '../models/OCIDescriptor.js'; export interface ImageSummary { /** diff --git a/lib/models/ManagerStatus.ts b/lib/models/ManagerStatus.ts index 050f541..87f11ae 100644 --- a/lib/models/ManagerStatus.ts +++ b/lib/models/ManagerStatus.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Reachability } from '../models/Reachability.js'; +import { type Reachability } from '../models/Reachability.js'; /** * ManagerStatus represents the status of a manager. It provides the current status of a node\'s manager component, if the node is a manager. diff --git a/lib/models/Mount.ts b/lib/models/Mount.ts index 1ffe5e7..bb1b35a 100644 --- a/lib/models/Mount.ts +++ b/lib/models/Mount.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { MountBindOptions } from '../models/MountBindOptions.js'; -import { MountImageOptions } from '../models/MountImageOptions.js'; -import { MountTmpfsOptions } from '../models/MountTmpfsOptions.js'; -import { MountVolumeOptions } from '../models/MountVolumeOptions.js'; +import { type MountBindOptions } from '../models/MountBindOptions.js'; +import { type MountImageOptions } from '../models/MountImageOptions.js'; +import { type MountTmpfsOptions } from '../models/MountTmpfsOptions.js'; +import { type MountVolumeOptions } from '../models/MountVolumeOptions.js'; export interface Mount { /** diff --git a/lib/models/MountVolumeOptions.ts b/lib/models/MountVolumeOptions.ts index 43d61d3..269f3d6 100644 --- a/lib/models/MountVolumeOptions.ts +++ b/lib/models/MountVolumeOptions.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { MountVolumeOptionsDriverConfig } from '../models/MountVolumeOptionsDriverConfig.js'; +import { type MountVolumeOptionsDriverConfig } from '../models/MountVolumeOptionsDriverConfig.js'; /** * Optional configuration for the `volume` type. diff --git a/lib/models/Network.ts b/lib/models/Network.ts index fb5b5b2..6a19dcd 100644 --- a/lib/models/Network.ts +++ b/lib/models/Network.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ConfigReference } from '../models/ConfigReference.js'; -import { IPAM } from '../models/IPAM.js'; -import { PeerInfo } from '../models/PeerInfo.js'; +import { type ConfigReference } from '../models/ConfigReference.js'; +import { type IPAM } from '../models/IPAM.js'; +import { type PeerInfo } from '../models/PeerInfo.js'; export interface Network { /** diff --git a/lib/models/NetworkConnectRequest.ts b/lib/models/NetworkConnectRequest.ts index 4fd4efa..afb2e98 100644 --- a/lib/models/NetworkConnectRequest.ts +++ b/lib/models/NetworkConnectRequest.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointSettings } from '../models/EndpointSettings.js'; +import { type EndpointSettings } from '../models/EndpointSettings.js'; export interface NetworkConnectRequest { /** diff --git a/lib/models/NetworkCreateRequest.ts b/lib/models/NetworkCreateRequest.ts index 8b2d7f3..a9ae552 100644 --- a/lib/models/NetworkCreateRequest.ts +++ b/lib/models/NetworkCreateRequest.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ConfigReference } from '../models/ConfigReference.js'; -import { IPAM } from '../models/IPAM.js'; +import { type ConfigReference } from '../models/ConfigReference.js'; +import { type IPAM } from '../models/IPAM.js'; export interface NetworkCreateRequest { /** diff --git a/lib/models/NetworkInspect.ts b/lib/models/NetworkInspect.ts index 4349760..a744983 100644 --- a/lib/models/NetworkInspect.ts +++ b/lib/models/NetworkInspect.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { ConfigReference } from '../models/ConfigReference.js'; -import { EndpointResource } from '../models/EndpointResource.js'; -import { IPAM } from '../models/IPAM.js'; -import { PeerInfo } from '../models/PeerInfo.js'; +import { type ConfigReference } from '../models/ConfigReference.js'; +import { type EndpointResource } from '../models/EndpointResource.js'; +import { type IPAM } from '../models/IPAM.js'; +import { type PeerInfo } from '../models/PeerInfo.js'; /** * The body of the \"get network\" http response message. diff --git a/lib/models/NetworkSettings.ts b/lib/models/NetworkSettings.ts index 9f547de..b8ea2f0 100644 --- a/lib/models/NetworkSettings.ts +++ b/lib/models/NetworkSettings.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { Address } from '../models/Address.js'; -import { EndpointSettings } from '../models/EndpointSettings.js'; -import { PortBinding } from '../models/PortBinding.js'; +import { type Address } from '../models/Address.js'; +import { type EndpointSettings } from '../models/EndpointSettings.js'; +import { type PortBinding } from '../models/PortBinding.js'; /** * NetworkSettings exposes the network settings in the API diff --git a/lib/models/NetworkSummary.ts b/lib/models/NetworkSummary.ts index be04c2c..9af7708 100644 --- a/lib/models/NetworkSummary.ts +++ b/lib/models/NetworkSummary.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ConfigReference } from '../models/ConfigReference.js'; -import { IPAM } from '../models/IPAM.js'; -import { PeerInfo } from '../models/PeerInfo.js'; +import { type ConfigReference } from '../models/ConfigReference.js'; +import { type IPAM } from '../models/IPAM.js'; +import { type PeerInfo } from '../models/PeerInfo.js'; /** * Network list response item diff --git a/lib/models/NetworkingConfig.ts b/lib/models/NetworkingConfig.ts index 06d8b7d..01c1014 100644 --- a/lib/models/NetworkingConfig.ts +++ b/lib/models/NetworkingConfig.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointSettings } from '../models/EndpointSettings.js'; +import { type EndpointSettings } from '../models/EndpointSettings.js'; /** * NetworkingConfig represents the container\'s networking configuration for each of its interfaces. It is used for the networking configs specified in the `docker create` and `docker network connect` commands. diff --git a/lib/models/Node.ts b/lib/models/Node.ts index 8ef3bbb..3fa3b4a 100644 --- a/lib/models/Node.ts +++ b/lib/models/Node.ts @@ -18,11 +18,11 @@ Do not edit the class manually. */ -import { ManagerStatus } from '../models/ManagerStatus.js'; -import { NodeDescription } from '../models/NodeDescription.js'; -import { NodeSpec } from '../models/NodeSpec.js'; -import { NodeStatus } from '../models/NodeStatus.js'; -import { ObjectVersion } from '../models/ObjectVersion.js'; +import { type ManagerStatus } from '../models/ManagerStatus.js'; +import { type NodeDescription } from '../models/NodeDescription.js'; +import { type NodeSpec } from '../models/NodeSpec.js'; +import { type NodeStatus } from '../models/NodeStatus.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; export interface Node { ID?: string; diff --git a/lib/models/NodeDescription.ts b/lib/models/NodeDescription.ts index 30e309c..f111dd2 100644 --- a/lib/models/NodeDescription.ts +++ b/lib/models/NodeDescription.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { EngineDescription } from '../models/EngineDescription.js'; -import { Platform } from '../models/Platform.js'; -import { ResourceObject } from '../models/ResourceObject.js'; -import { TLSInfo } from '../models/TLSInfo.js'; +import { type EngineDescription } from '../models/EngineDescription.js'; +import { type Platform } from '../models/Platform.js'; +import { type ResourceObject } from '../models/ResourceObject.js'; +import { type TLSInfo } from '../models/TLSInfo.js'; /** * NodeDescription encapsulates the properties of the Node as reported by the agent. diff --git a/lib/models/NodeStatus.ts b/lib/models/NodeStatus.ts index 220a90d..4a4d8b9 100644 --- a/lib/models/NodeStatus.ts +++ b/lib/models/NodeStatus.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { NodeState } from '../models/NodeState.js'; +import { type NodeState } from '../models/NodeState.js'; /** * NodeStatus represents the status of a node. It provides the current status of the node, as seen by the manager. diff --git a/lib/models/OCIDescriptor.ts b/lib/models/OCIDescriptor.ts index f41af12..39b38a9 100644 --- a/lib/models/OCIDescriptor.ts +++ b/lib/models/OCIDescriptor.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { OCIPlatform } from '../models/OCIPlatform.js'; +import { type OCIPlatform } from '../models/OCIPlatform.js'; /** * A descriptor struct containing digest, media type, and size, as defined in the [OCI Content Descriptors Specification](https://github.com/opencontainers/image-spec/blob/v1.0.1/descriptor.md). diff --git a/lib/models/Plugin.ts b/lib/models/Plugin.ts index dbd8229..6996f5d 100644 --- a/lib/models/Plugin.ts +++ b/lib/models/Plugin.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { PluginConfig } from '../models/PluginConfig.js'; -import { PluginSettings } from '../models/PluginSettings.js'; +import { type PluginConfig } from '../models/PluginConfig.js'; +import { type PluginSettings } from '../models/PluginSettings.js'; /** * A plugin for the Engine API diff --git a/lib/models/PluginConfig.ts b/lib/models/PluginConfig.ts index 8d5b4cd..d452f95 100644 --- a/lib/models/PluginConfig.ts +++ b/lib/models/PluginConfig.ts @@ -18,14 +18,14 @@ Do not edit the class manually. */ -import { PluginConfigArgs } from '../models/PluginConfigArgs.js'; -import { PluginConfigInterface } from '../models/PluginConfigInterface.js'; -import { PluginConfigLinux } from '../models/PluginConfigLinux.js'; -import { PluginConfigNetwork } from '../models/PluginConfigNetwork.js'; -import { PluginConfigRootfs } from '../models/PluginConfigRootfs.js'; -import { PluginConfigUser } from '../models/PluginConfigUser.js'; -import { PluginEnv } from '../models/PluginEnv.js'; -import { PluginMount } from '../models/PluginMount.js'; +import { type PluginConfigArgs } from '../models/PluginConfigArgs.js'; +import { type PluginConfigInterface } from '../models/PluginConfigInterface.js'; +import { type PluginConfigLinux } from '../models/PluginConfigLinux.js'; +import { type PluginConfigNetwork } from '../models/PluginConfigNetwork.js'; +import { type PluginConfigRootfs } from '../models/PluginConfigRootfs.js'; +import { type PluginConfigUser } from '../models/PluginConfigUser.js'; +import { type PluginEnv } from '../models/PluginEnv.js'; +import { type PluginMount } from '../models/PluginMount.js'; /** * The config of a plugin. diff --git a/lib/models/PluginConfigLinux.ts b/lib/models/PluginConfigLinux.ts index 0b52115..090069c 100644 --- a/lib/models/PluginConfigLinux.ts +++ b/lib/models/PluginConfigLinux.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { PluginDevice } from '../models/PluginDevice.js'; +import { type PluginDevice } from '../models/PluginDevice.js'; export interface PluginConfigLinux { Capabilities: Array; diff --git a/lib/models/PluginSettings.ts b/lib/models/PluginSettings.ts index 57dd95c..b801bf8 100644 --- a/lib/models/PluginSettings.ts +++ b/lib/models/PluginSettings.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { PluginDevice } from '../models/PluginDevice.js'; -import { PluginMount } from '../models/PluginMount.js'; +import { type PluginDevice } from '../models/PluginDevice.js'; +import { type PluginMount } from '../models/PluginMount.js'; /** * user-configurable settings for the plugin. diff --git a/lib/models/PortStatus.ts b/lib/models/PortStatus.ts index 1211207..6a9a059 100644 --- a/lib/models/PortStatus.ts +++ b/lib/models/PortStatus.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { EndpointPortConfig } from '../models/EndpointPortConfig.js'; +import { type EndpointPortConfig } from '../models/EndpointPortConfig.js'; /** * represents the port status of a task\'s host ports whose service has published host ports diff --git a/lib/models/PushImageInfo.ts b/lib/models/PushImageInfo.ts index 331d1c1..80961a3 100644 --- a/lib/models/PushImageInfo.ts +++ b/lib/models/PushImageInfo.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ErrorDetail } from '../models/ErrorDetail.js'; -import { ProgressDetail } from '../models/ProgressDetail.js'; +import { type ErrorDetail } from '../models/ErrorDetail.js'; +import { type ProgressDetail } from '../models/ProgressDetail.js'; export interface PushImageInfo { ErrorDetail?: ErrorDetail; diff --git a/lib/models/RegistryServiceConfig.ts b/lib/models/RegistryServiceConfig.ts index 27bc4a0..23ab0f1 100644 --- a/lib/models/RegistryServiceConfig.ts +++ b/lib/models/RegistryServiceConfig.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { IndexInfo } from '../models/IndexInfo.js'; +import { type IndexInfo } from '../models/IndexInfo.js'; /** * RegistryServiceConfig stores daemon registry services configuration. diff --git a/lib/models/ResourceObject.ts b/lib/models/ResourceObject.ts index f8dbc98..53b0cfb 100644 --- a/lib/models/ResourceObject.ts +++ b/lib/models/ResourceObject.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { GenericResourcesInner } from '../models/GenericResourcesInner.js'; +import { type GenericResourcesInner } from '../models/GenericResourcesInner.js'; /** * An object describing the resources which can be advertised by a node and requested by a task. diff --git a/lib/models/Resources.ts b/lib/models/Resources.ts index 275cf5a..5493492 100644 --- a/lib/models/Resources.ts +++ b/lib/models/Resources.ts @@ -18,11 +18,11 @@ Do not edit the class manually. */ -import { DeviceMapping } from '../models/DeviceMapping.js'; -import { DeviceRequest } from '../models/DeviceRequest.js'; -import { ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; -import { ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; -import { ThrottleDevice } from '../models/ThrottleDevice.js'; +import { type DeviceMapping } from '../models/DeviceMapping.js'; +import { type DeviceRequest } from '../models/DeviceRequest.js'; +import { type ResourcesBlkioWeightDeviceInner } from '../models/ResourcesBlkioWeightDeviceInner.js'; +import { type ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; +import { type ThrottleDevice } from '../models/ThrottleDevice.js'; /** * A container\'s resources (cgroups config, ulimits, etc) diff --git a/lib/models/Secret.ts b/lib/models/Secret.ts index 3d16fc4..b45417f 100644 --- a/lib/models/Secret.ts +++ b/lib/models/Secret.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ObjectVersion } from '../models/ObjectVersion.js'; -import { SecretSpec } from '../models/SecretSpec.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; +import { type SecretSpec } from '../models/SecretSpec.js'; export interface Secret { ID?: string; diff --git a/lib/models/SecretCreateRequest.ts b/lib/models/SecretCreateRequest.ts index 86f7151..13b7b92 100644 --- a/lib/models/SecretCreateRequest.ts +++ b/lib/models/SecretCreateRequest.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Driver } from '../models/Driver.js'; +import { type Driver } from '../models/Driver.js'; export interface SecretCreateRequest { /** diff --git a/lib/models/SecretSpec.ts b/lib/models/SecretSpec.ts index a870c2a..cf4cc41 100644 --- a/lib/models/SecretSpec.ts +++ b/lib/models/SecretSpec.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Driver } from '../models/Driver.js'; +import { type Driver } from '../models/Driver.js'; export interface SecretSpec { /** diff --git a/lib/models/Service.ts b/lib/models/Service.ts index 3d3dbcd..b9653ba 100644 --- a/lib/models/Service.ts +++ b/lib/models/Service.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { ObjectVersion } from '../models/ObjectVersion.js'; -import { ServiceEndpoint } from '../models/ServiceEndpoint.js'; -import { ServiceJobStatus } from '../models/ServiceJobStatus.js'; -import { ServiceServiceStatus } from '../models/ServiceServiceStatus.js'; -import { ServiceSpec } from '../models/ServiceSpec.js'; -import { ServiceUpdateStatus } from '../models/ServiceUpdateStatus.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; +import { type ServiceEndpoint } from '../models/ServiceEndpoint.js'; +import { type ServiceJobStatus } from '../models/ServiceJobStatus.js'; +import { type ServiceServiceStatus } from '../models/ServiceServiceStatus.js'; +import { type ServiceSpec } from '../models/ServiceSpec.js'; +import { type ServiceUpdateStatus } from '../models/ServiceUpdateStatus.js'; export interface Service { ID?: string; diff --git a/lib/models/ServiceCreateRequest.ts b/lib/models/ServiceCreateRequest.ts index 04f9751..dca7d10 100644 --- a/lib/models/ServiceCreateRequest.ts +++ b/lib/models/ServiceCreateRequest.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { EndpointSpec } from '../models/EndpointSpec.js'; -import { NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; -import { ServiceSpecMode } from '../models/ServiceSpecMode.js'; -import { ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; -import { ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; -import { TaskSpec } from '../models/TaskSpec.js'; +import { type EndpointSpec } from '../models/EndpointSpec.js'; +import { type NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; +import { type ServiceSpecMode } from '../models/ServiceSpecMode.js'; +import { type ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; +import { type ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; +import { type TaskSpec } from '../models/TaskSpec.js'; export interface ServiceCreateRequest { /** diff --git a/lib/models/ServiceEndpoint.ts b/lib/models/ServiceEndpoint.ts index 751314e..1aed34f 100644 --- a/lib/models/ServiceEndpoint.ts +++ b/lib/models/ServiceEndpoint.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { EndpointPortConfig } from '../models/EndpointPortConfig.js'; -import { EndpointSpec } from '../models/EndpointSpec.js'; -import { ServiceEndpointVirtualIPsInner } from '../models/ServiceEndpointVirtualIPsInner.js'; +import { type EndpointPortConfig } from '../models/EndpointPortConfig.js'; +import { type EndpointSpec } from '../models/EndpointSpec.js'; +import { type ServiceEndpointVirtualIPsInner } from '../models/ServiceEndpointVirtualIPsInner.js'; export interface ServiceEndpoint { Spec?: EndpointSpec; diff --git a/lib/models/ServiceInfo.ts b/lib/models/ServiceInfo.ts index 1d812cf..f591b5e 100644 --- a/lib/models/ServiceInfo.ts +++ b/lib/models/ServiceInfo.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { NetworkTaskInfo } from '../models/NetworkTaskInfo.js'; +import { type NetworkTaskInfo } from '../models/NetworkTaskInfo.js'; /** * represents service parameters with the list of service\'s tasks diff --git a/lib/models/ServiceJobStatus.ts b/lib/models/ServiceJobStatus.ts index 7ecf181..e780757 100644 --- a/lib/models/ServiceJobStatus.ts +++ b/lib/models/ServiceJobStatus.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ObjectVersion } from '../models/ObjectVersion.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; /** * The status of the service when it is in one of ReplicatedJob or GlobalJob modes. Absent on Replicated and Global mode services. The JobIteration is an ObjectVersion, but unlike the Service\'s version, does not need to be sent with an update request. diff --git a/lib/models/ServiceSpec.ts b/lib/models/ServiceSpec.ts index ff2421f..eeee153 100644 --- a/lib/models/ServiceSpec.ts +++ b/lib/models/ServiceSpec.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { EndpointSpec } from '../models/EndpointSpec.js'; -import { NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; -import { ServiceSpecMode } from '../models/ServiceSpecMode.js'; -import { ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; -import { ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; -import { TaskSpec } from '../models/TaskSpec.js'; +import { type EndpointSpec } from '../models/EndpointSpec.js'; +import { type NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; +import { type ServiceSpecMode } from '../models/ServiceSpecMode.js'; +import { type ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; +import { type ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; +import { type TaskSpec } from '../models/TaskSpec.js'; /** * User modifiable configuration for a service. diff --git a/lib/models/ServiceSpecMode.ts b/lib/models/ServiceSpecMode.ts index 0c061a1..4f78a69 100644 --- a/lib/models/ServiceSpecMode.ts +++ b/lib/models/ServiceSpecMode.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ServiceSpecModeReplicated } from '../models/ServiceSpecModeReplicated.js'; -import { ServiceSpecModeReplicatedJob } from '../models/ServiceSpecModeReplicatedJob.js'; +import { type ServiceSpecModeReplicated } from '../models/ServiceSpecModeReplicated.js'; +import { type ServiceSpecModeReplicatedJob } from '../models/ServiceSpecModeReplicatedJob.js'; /** * Scheduling mode for the service. diff --git a/lib/models/ServiceUpdateRequest.ts b/lib/models/ServiceUpdateRequest.ts index 3e5b95b..fd3c2b9 100644 --- a/lib/models/ServiceUpdateRequest.ts +++ b/lib/models/ServiceUpdateRequest.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { EndpointSpec } from '../models/EndpointSpec.js'; -import { NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; -import { ServiceSpecMode } from '../models/ServiceSpecMode.js'; -import { ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; -import { ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; -import { TaskSpec } from '../models/TaskSpec.js'; +import { type EndpointSpec } from '../models/EndpointSpec.js'; +import { type NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; +import { type ServiceSpecMode } from '../models/ServiceSpecMode.js'; +import { type ServiceSpecRollbackConfig } from '../models/ServiceSpecRollbackConfig.js'; +import { type ServiceSpecUpdateConfig } from '../models/ServiceSpecUpdateConfig.js'; +import { type TaskSpec } from '../models/TaskSpec.js'; export interface ServiceUpdateRequest { /** diff --git a/lib/models/Swarm.ts b/lib/models/Swarm.ts index 6a33bd8..5c2c825 100644 --- a/lib/models/Swarm.ts +++ b/lib/models/Swarm.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { JoinTokens } from '../models/JoinTokens.js'; -import { ObjectVersion } from '../models/ObjectVersion.js'; -import { SwarmSpec } from '../models/SwarmSpec.js'; -import { TLSInfo } from '../models/TLSInfo.js'; +import { type JoinTokens } from '../models/JoinTokens.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; +import { type SwarmSpec } from '../models/SwarmSpec.js'; +import { type TLSInfo } from '../models/TLSInfo.js'; export interface Swarm { /** diff --git a/lib/models/SwarmInfo.ts b/lib/models/SwarmInfo.ts index 7d5a0e3..45b71a5 100644 --- a/lib/models/SwarmInfo.ts +++ b/lib/models/SwarmInfo.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ClusterInfo } from '../models/ClusterInfo.js'; -import { LocalNodeState } from '../models/LocalNodeState.js'; -import { PeerNode } from '../models/PeerNode.js'; +import { type ClusterInfo } from '../models/ClusterInfo.js'; +import { type LocalNodeState } from '../models/LocalNodeState.js'; +import { type PeerNode } from '../models/PeerNode.js'; /** * Represents generic information about swarm. diff --git a/lib/models/SwarmInitRequest.ts b/lib/models/SwarmInitRequest.ts index 50e8e2b..fb0a181 100644 --- a/lib/models/SwarmInitRequest.ts +++ b/lib/models/SwarmInitRequest.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { SwarmSpec } from '../models/SwarmSpec.js'; +import { type SwarmSpec } from '../models/SwarmSpec.js'; export interface SwarmInitRequest { /** diff --git a/lib/models/SwarmSpec.ts b/lib/models/SwarmSpec.ts index 701551c..a9b0694 100644 --- a/lib/models/SwarmSpec.ts +++ b/lib/models/SwarmSpec.ts @@ -18,12 +18,12 @@ Do not edit the class manually. */ -import { SwarmSpecCAConfig } from '../models/SwarmSpecCAConfig.js'; -import { SwarmSpecDispatcher } from '../models/SwarmSpecDispatcher.js'; -import { SwarmSpecEncryptionConfig } from '../models/SwarmSpecEncryptionConfig.js'; -import { SwarmSpecOrchestration } from '../models/SwarmSpecOrchestration.js'; -import { SwarmSpecRaft } from '../models/SwarmSpecRaft.js'; -import { SwarmSpecTaskDefaults } from '../models/SwarmSpecTaskDefaults.js'; +import { type SwarmSpecCAConfig } from '../models/SwarmSpecCAConfig.js'; +import { type SwarmSpecDispatcher } from '../models/SwarmSpecDispatcher.js'; +import { type SwarmSpecEncryptionConfig } from '../models/SwarmSpecEncryptionConfig.js'; +import { type SwarmSpecOrchestration } from '../models/SwarmSpecOrchestration.js'; +import { type SwarmSpecRaft } from '../models/SwarmSpecRaft.js'; +import { type SwarmSpecTaskDefaults } from '../models/SwarmSpecTaskDefaults.js'; /** * User modifiable swarm configuration. diff --git a/lib/models/SwarmSpecCAConfig.ts b/lib/models/SwarmSpecCAConfig.ts index ce0b0ab..659c5f2 100644 --- a/lib/models/SwarmSpecCAConfig.ts +++ b/lib/models/SwarmSpecCAConfig.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { SwarmSpecCAConfigExternalCAsInner } from '../models/SwarmSpecCAConfigExternalCAsInner.js'; +import { type SwarmSpecCAConfigExternalCAsInner } from '../models/SwarmSpecCAConfigExternalCAsInner.js'; /** * CA configuration. diff --git a/lib/models/SwarmSpecTaskDefaults.ts b/lib/models/SwarmSpecTaskDefaults.ts index 08504ba..37062e5 100644 --- a/lib/models/SwarmSpecTaskDefaults.ts +++ b/lib/models/SwarmSpecTaskDefaults.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { SwarmSpecTaskDefaultsLogDriver } from '../models/SwarmSpecTaskDefaultsLogDriver.js'; +import { type SwarmSpecTaskDefaultsLogDriver } from '../models/SwarmSpecTaskDefaultsLogDriver.js'; /** * Defaults for creating tasks in this cluster. diff --git a/lib/models/SystemDataUsageResponse.ts b/lib/models/SystemDataUsageResponse.ts index 3f6a99a..032de14 100644 --- a/lib/models/SystemDataUsageResponse.ts +++ b/lib/models/SystemDataUsageResponse.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { BuildCache } from '../models/BuildCache.js'; -import { ContainerSummary } from '../models/ContainerSummary.js'; -import { ImageSummary } from '../models/ImageSummary.js'; -import { Volume } from '../models/Volume.js'; +import { type BuildCache } from '../models/BuildCache.js'; +import { type ContainerSummary } from '../models/ContainerSummary.js'; +import { type ImageSummary } from '../models/ImageSummary.js'; +import { type Volume } from '../models/Volume.js'; export interface SystemDataUsageResponse { LayersSize?: number; diff --git a/lib/models/SystemInfo.ts b/lib/models/SystemInfo.ts index abaeedf..5a40463 100644 --- a/lib/models/SystemInfo.ts +++ b/lib/models/SystemInfo.ts @@ -18,16 +18,16 @@ Do not edit the class manually. */ -import { Commit } from '../models/Commit.js'; -import { ContainerdInfo } from '../models/ContainerdInfo.js'; -import { DeviceInfo } from '../models/DeviceInfo.js'; -import { FirewallInfo } from '../models/FirewallInfo.js'; -import { GenericResourcesInner } from '../models/GenericResourcesInner.js'; -import { PluginsInfo } from '../models/PluginsInfo.js'; -import { RegistryServiceConfig } from '../models/RegistryServiceConfig.js'; -import { Runtime } from '../models/Runtime.js'; -import { SwarmInfo } from '../models/SwarmInfo.js'; -import { SystemInfoDefaultAddressPoolsInner } from '../models/SystemInfoDefaultAddressPoolsInner.js'; +import { type Commit } from '../models/Commit.js'; +import { type ContainerdInfo } from '../models/ContainerdInfo.js'; +import { type DeviceInfo } from '../models/DeviceInfo.js'; +import { type FirewallInfo } from '../models/FirewallInfo.js'; +import { type GenericResourcesInner } from '../models/GenericResourcesInner.js'; +import { type PluginsInfo } from '../models/PluginsInfo.js'; +import { type RegistryServiceConfig } from '../models/RegistryServiceConfig.js'; +import { type Runtime } from '../models/Runtime.js'; +import { type SwarmInfo } from '../models/SwarmInfo.js'; +import { type SystemInfoDefaultAddressPoolsInner } from '../models/SystemInfoDefaultAddressPoolsInner.js'; export interface SystemInfo { /** diff --git a/lib/models/SystemVersion.ts b/lib/models/SystemVersion.ts index ed7bffa..c4a28de 100644 --- a/lib/models/SystemVersion.ts +++ b/lib/models/SystemVersion.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { SystemVersionComponentsInner } from '../models/SystemVersionComponentsInner.js'; -import { SystemVersionPlatform } from '../models/SystemVersionPlatform.js'; +import { type SystemVersionComponentsInner } from '../models/SystemVersionComponentsInner.js'; +import { type SystemVersionPlatform } from '../models/SystemVersionPlatform.js'; /** * Response of Engine API: GET \"/version\" diff --git a/lib/models/Task.ts b/lib/models/Task.ts index 13e2bbd..bcec4ac 100644 --- a/lib/models/Task.ts +++ b/lib/models/Task.ts @@ -18,11 +18,11 @@ Do not edit the class manually. */ -import { GenericResourcesInner } from '../models/GenericResourcesInner.js'; -import { ObjectVersion } from '../models/ObjectVersion.js'; -import { TaskSpec } from '../models/TaskSpec.js'; -import { TaskState } from '../models/TaskState.js'; -import { TaskStatus } from '../models/TaskStatus.js'; +import { type GenericResourcesInner } from '../models/GenericResourcesInner.js'; +import { type ObjectVersion } from '../models/ObjectVersion.js'; +import { type TaskSpec } from '../models/TaskSpec.js'; +import { type TaskState } from '../models/TaskState.js'; +import { type TaskStatus } from '../models/TaskStatus.js'; export interface Task { /** diff --git a/lib/models/TaskSpec.ts b/lib/models/TaskSpec.ts index 0591d21..d831824 100644 --- a/lib/models/TaskSpec.ts +++ b/lib/models/TaskSpec.ts @@ -18,14 +18,14 @@ Do not edit the class manually. */ -import { NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; -import { TaskSpecContainerSpec } from '../models/TaskSpecContainerSpec.js'; -import { TaskSpecLogDriver } from '../models/TaskSpecLogDriver.js'; -import { TaskSpecNetworkAttachmentSpec } from '../models/TaskSpecNetworkAttachmentSpec.js'; -import { TaskSpecPlacement } from '../models/TaskSpecPlacement.js'; -import { TaskSpecPluginSpec } from '../models/TaskSpecPluginSpec.js'; -import { TaskSpecResources } from '../models/TaskSpecResources.js'; -import { TaskSpecRestartPolicy } from '../models/TaskSpecRestartPolicy.js'; +import { type NetworkAttachmentConfig } from '../models/NetworkAttachmentConfig.js'; +import { type TaskSpecContainerSpec } from '../models/TaskSpecContainerSpec.js'; +import { type TaskSpecLogDriver } from '../models/TaskSpecLogDriver.js'; +import { type TaskSpecNetworkAttachmentSpec } from '../models/TaskSpecNetworkAttachmentSpec.js'; +import { type TaskSpecPlacement } from '../models/TaskSpecPlacement.js'; +import { type TaskSpecPluginSpec } from '../models/TaskSpecPluginSpec.js'; +import { type TaskSpecResources } from '../models/TaskSpecResources.js'; +import { type TaskSpecRestartPolicy } from '../models/TaskSpecRestartPolicy.js'; /** * User modifiable task configuration. diff --git a/lib/models/TaskSpecContainerSpec.ts b/lib/models/TaskSpecContainerSpec.ts index 2d4e1ce..c9a133e 100644 --- a/lib/models/TaskSpecContainerSpec.ts +++ b/lib/models/TaskSpecContainerSpec.ts @@ -18,13 +18,13 @@ Do not edit the class manually. */ -import { HealthConfig } from '../models/HealthConfig.js'; -import { Mount } from '../models/Mount.js'; -import { ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; -import { TaskSpecContainerSpecConfigsInner } from '../models/TaskSpecContainerSpecConfigsInner.js'; -import { TaskSpecContainerSpecDNSConfig } from '../models/TaskSpecContainerSpecDNSConfig.js'; -import { TaskSpecContainerSpecPrivileges } from '../models/TaskSpecContainerSpecPrivileges.js'; -import { TaskSpecContainerSpecSecretsInner } from '../models/TaskSpecContainerSpecSecretsInner.js'; +import { type HealthConfig } from '../models/HealthConfig.js'; +import { type Mount } from '../models/Mount.js'; +import { type ResourcesUlimitsInner } from '../models/ResourcesUlimitsInner.js'; +import { type TaskSpecContainerSpecConfigsInner } from '../models/TaskSpecContainerSpecConfigsInner.js'; +import { type TaskSpecContainerSpecDNSConfig } from '../models/TaskSpecContainerSpecDNSConfig.js'; +import { type TaskSpecContainerSpecPrivileges } from '../models/TaskSpecContainerSpecPrivileges.js'; +import { type TaskSpecContainerSpecSecretsInner } from '../models/TaskSpecContainerSpecSecretsInner.js'; /** * Container spec for the service.


> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are > mutually exclusive. PluginSpec is only used when the Runtime field > is set to `plugin`. NetworkAttachmentSpec is used when the Runtime > field is set to `attachment`. diff --git a/lib/models/TaskSpecContainerSpecConfigsInner.ts b/lib/models/TaskSpecContainerSpecConfigsInner.ts index d3f20f7..cc7eaec 100644 --- a/lib/models/TaskSpecContainerSpecConfigsInner.ts +++ b/lib/models/TaskSpecContainerSpecConfigsInner.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { TaskSpecContainerSpecConfigsInnerFile } from '../models/TaskSpecContainerSpecConfigsInnerFile.js'; +import { type TaskSpecContainerSpecConfigsInnerFile } from '../models/TaskSpecContainerSpecConfigsInnerFile.js'; export interface TaskSpecContainerSpecConfigsInner { File?: TaskSpecContainerSpecConfigsInnerFile; diff --git a/lib/models/TaskSpecContainerSpecPrivileges.ts b/lib/models/TaskSpecContainerSpecPrivileges.ts index 2df5fda..202e41f 100644 --- a/lib/models/TaskSpecContainerSpecPrivileges.ts +++ b/lib/models/TaskSpecContainerSpecPrivileges.ts @@ -18,10 +18,10 @@ Do not edit the class manually. */ -import { TaskSpecContainerSpecPrivilegesAppArmor } from '../models/TaskSpecContainerSpecPrivilegesAppArmor.js'; -import { TaskSpecContainerSpecPrivilegesCredentialSpec } from '../models/TaskSpecContainerSpecPrivilegesCredentialSpec.js'; -import { TaskSpecContainerSpecPrivilegesSELinuxContext } from '../models/TaskSpecContainerSpecPrivilegesSELinuxContext.js'; -import { TaskSpecContainerSpecPrivilegesSeccomp } from '../models/TaskSpecContainerSpecPrivilegesSeccomp.js'; +import { type TaskSpecContainerSpecPrivilegesAppArmor } from '../models/TaskSpecContainerSpecPrivilegesAppArmor.js'; +import { type TaskSpecContainerSpecPrivilegesCredentialSpec } from '../models/TaskSpecContainerSpecPrivilegesCredentialSpec.js'; +import { type TaskSpecContainerSpecPrivilegesSELinuxContext } from '../models/TaskSpecContainerSpecPrivilegesSELinuxContext.js'; +import { type TaskSpecContainerSpecPrivilegesSeccomp } from '../models/TaskSpecContainerSpecPrivilegesSeccomp.js'; /** * Security options for the container diff --git a/lib/models/TaskSpecContainerSpecSecretsInner.ts b/lib/models/TaskSpecContainerSpecSecretsInner.ts index 17ec5de..081e207 100644 --- a/lib/models/TaskSpecContainerSpecSecretsInner.ts +++ b/lib/models/TaskSpecContainerSpecSecretsInner.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { TaskSpecContainerSpecSecretsInnerFile } from '../models/TaskSpecContainerSpecSecretsInnerFile.js'; +import { type TaskSpecContainerSpecSecretsInnerFile } from '../models/TaskSpecContainerSpecSecretsInnerFile.js'; export interface TaskSpecContainerSpecSecretsInner { File?: TaskSpecContainerSpecSecretsInnerFile; diff --git a/lib/models/TaskSpecPlacement.ts b/lib/models/TaskSpecPlacement.ts index a8c77df..0264d15 100644 --- a/lib/models/TaskSpecPlacement.ts +++ b/lib/models/TaskSpecPlacement.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { Platform } from '../models/Platform.js'; -import { TaskSpecPlacementPreferencesInner } from '../models/TaskSpecPlacementPreferencesInner.js'; +import { type Platform } from '../models/Platform.js'; +import { type TaskSpecPlacementPreferencesInner } from '../models/TaskSpecPlacementPreferencesInner.js'; export interface TaskSpecPlacement { /** diff --git a/lib/models/TaskSpecPlacementPreferencesInner.ts b/lib/models/TaskSpecPlacementPreferencesInner.ts index d22db5a..b0acd4e 100644 --- a/lib/models/TaskSpecPlacementPreferencesInner.ts +++ b/lib/models/TaskSpecPlacementPreferencesInner.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { TaskSpecPlacementPreferencesInnerSpread } from '../models/TaskSpecPlacementPreferencesInnerSpread.js'; +import { type TaskSpecPlacementPreferencesInnerSpread } from '../models/TaskSpecPlacementPreferencesInnerSpread.js'; export interface TaskSpecPlacementPreferencesInner { Spread?: TaskSpecPlacementPreferencesInnerSpread; diff --git a/lib/models/TaskSpecPluginSpec.ts b/lib/models/TaskSpecPluginSpec.ts index b0945f2..8eec86a 100644 --- a/lib/models/TaskSpecPluginSpec.ts +++ b/lib/models/TaskSpecPluginSpec.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { PluginPrivilege } from '../models/PluginPrivilege.js'; +import { type PluginPrivilege } from '../models/PluginPrivilege.js'; /** * Plugin spec for the service. *(Experimental release only.)*


> **Note**: ContainerSpec, NetworkAttachmentSpec, and PluginSpec are > mutually exclusive. PluginSpec is only used when the Runtime field > is set to `plugin`. NetworkAttachmentSpec is used when the Runtime > field is set to `attachment`. diff --git a/lib/models/TaskSpecResources.ts b/lib/models/TaskSpecResources.ts index 12cbdca..83d48f0 100644 --- a/lib/models/TaskSpecResources.ts +++ b/lib/models/TaskSpecResources.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { Limit } from '../models/Limit.js'; -import { ResourceObject } from '../models/ResourceObject.js'; +import { type Limit } from '../models/Limit.js'; +import { type ResourceObject } from '../models/ResourceObject.js'; /** * Resource requirements which apply to each individual container created as part of the service. diff --git a/lib/models/TaskStatus.ts b/lib/models/TaskStatus.ts index dbea2b2..c12308a 100644 --- a/lib/models/TaskStatus.ts +++ b/lib/models/TaskStatus.ts @@ -18,9 +18,9 @@ Do not edit the class manually. */ -import { ContainerStatus } from '../models/ContainerStatus.js'; -import { PortStatus } from '../models/PortStatus.js'; -import { TaskState } from '../models/TaskState.js'; +import { type ContainerStatus } from '../models/ContainerStatus.js'; +import { type PortStatus } from '../models/PortStatus.js'; +import { type TaskState } from '../models/TaskState.js'; /** * represents the status of a task. diff --git a/lib/models/Volume.ts b/lib/models/Volume.ts index 98cd4fb..f35fc17 100644 --- a/lib/models/Volume.ts +++ b/lib/models/Volume.ts @@ -18,8 +18,8 @@ Do not edit the class manually. */ -import { ClusterVolume } from '../models/ClusterVolume.js'; -import { VolumeUsageData } from '../models/VolumeUsageData.js'; +import { type ClusterVolume } from '../models/ClusterVolume.js'; +import { type VolumeUsageData } from '../models/VolumeUsageData.js'; export interface Volume { /** diff --git a/lib/models/VolumeCreateOptions.ts b/lib/models/VolumeCreateOptions.ts index d3ff40c..ae7268c 100644 --- a/lib/models/VolumeCreateOptions.ts +++ b/lib/models/VolumeCreateOptions.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; +import { type ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; /** * Volume configuration diff --git a/lib/models/VolumeListResponse.ts b/lib/models/VolumeListResponse.ts index 8e2fb7f..4023579 100644 --- a/lib/models/VolumeListResponse.ts +++ b/lib/models/VolumeListResponse.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { Volume } from '../models/Volume.js'; +import { type Volume } from '../models/Volume.js'; /** * Volume list response diff --git a/lib/models/VolumeUpdateRequest.ts b/lib/models/VolumeUpdateRequest.ts index 3490bc7..c8529ed 100644 --- a/lib/models/VolumeUpdateRequest.ts +++ b/lib/models/VolumeUpdateRequest.ts @@ -18,7 +18,7 @@ Do not edit the class manually. */ -import { ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; +import { type ClusterVolumeSpec } from '../models/ClusterVolumeSpec.js'; /** * Volume configuration diff --git a/lib/socket.ts b/lib/socket.ts index 51dfe0c..c943d6d 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -1,4 +1,5 @@ import * as net from 'net'; +import type { ClientRequestArgs } from 'http'; import * as http from 'http'; import * as stream from 'stream'; @@ -24,8 +25,8 @@ export class SocketAgent extends http.Agent { // Override createConnection to use our socket factory this.createConnection = ( - options: any, - callback?: (err: Error | null, socket?: stream.Duplex) => void, + options: ClientRequestArgs, + callback?: (err: Error | null, socket: stream.Duplex) => void, ): stream.Duplex => { const socket = this.socketFactory(); socket.setNoDelay(true); @@ -40,7 +41,7 @@ export class SocketAgent extends http.Agent { const onError = (error: Error) => { socket.removeListener('connect', onConnect); - callback(error); + callback(error, socket); }; socket.once('connect', onConnect); diff --git a/lib/ssh.ts b/lib/ssh.ts index a0bbca0..770c1ba 100644 --- a/lib/ssh.ts +++ b/lib/ssh.ts @@ -84,29 +84,32 @@ export class SSH { conn.on('ready', () => { // Create a Unix socket connection through SSH - conn.openssh_forwardInStreamLocal(socketPath, (err, stream) => { - if (err) { - conn.end(); - sshStream.emit( - 'error', - new Error( - `Failed to create SSH tunnel to ${socketPath}: ${err.message}`, - ), - ); - return; - } - - // Pipe the SSH stream to our socket wrapper - stream.pipe(sshStream); - sshStream.pipe(stream); - - // Handle SSH connection cleanup - sshStream.on('close', () => { - conn.end(); - }); - - sshStream.emit('connect'); - }); + conn.openssh_forwardOutStreamLocal( + socketPath, + (err, stream) => { + if (err) { + conn.end(); + sshStream.emit( + 'error', + new Error( + `Failed to create SSH tunnel to ${socketPath}: ${err.message}`, + ), + ); + return; + } + + // Pipe the SSH stream to our socket wrapper + stream.pipe(sshStream); + sshStream.pipe(stream); + + // Handle SSH connection cleanup + sshStream.on('close', () => { + conn.end(); + }); + + sshStream.emit('connect'); + }, + ); }); conn.on('error', (err) => { diff --git a/lib/tls.ts b/lib/tls.ts index 189393a..6f77f95 100644 --- a/lib/tls.ts +++ b/lib/tls.ts @@ -1,5 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; +import { getErrorMessage } from './util.js'; /** * TLS certificate utilities for secure Docker connections @@ -39,7 +40,7 @@ export class TLS { return tlsOptions; } catch (error) { throw new Error( - `Failed to load TLS certificates from ${certPath}: ${error.message}`, + `Failed to load TLS certificates from ${certPath}: ${getErrorMessage(error)}`, ); } } diff --git a/lib/util.ts b/lib/util.ts new file mode 100644 index 0000000..1ff6e8e --- /dev/null +++ b/lib/util.ts @@ -0,0 +1,47 @@ +export function isFileNotFoundError(error: unknown): boolean { + return (error as NodeJS.ErrnoException)?.code === 'ENOENT'; +} + +export function getErrorMessage(error: unknown): string | undefined { + if (!error) { + return; + } + if (typeof error === 'string') { + return error; + } + if (error instanceof Error) { + return error.message; + } + if ( + typeof error === 'object' && + 'message' in error && + typeof error.message === 'string' + ) { + return error.message; + } + return; +} + +export function parseIntWithDefault( + value: string | undefined, + defaultValue: number, +) { + if (value === undefined) { + return defaultValue; + } + const number = parseInt(value); + return Number.isNaN(number) ? defaultValue : number; +} + +export function parseDockerHost( + dockerHost: string, + defaultPort: number, +): { host: string; port: number } { + const tcpAddress = dockerHost.substring(6); // Remove "tcp://" prefix + const [host, portStr] = tcpAddress.split(':'); + if (!host) { + throw new Error(`Invalid Docker host: ${dockerHost}`); + } + const port = parseIntWithDefault(portStr, defaultPort); + return { host, port }; +} diff --git a/makefile b/makefile index 81167a4..4a8f1af 100644 --- a/makefile +++ b/makefile @@ -5,6 +5,9 @@ build: npm run build test: + npm run typecheck npm run test + npm run format.check + npm run lint .PHONY: generate build test \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 812d2b9..660db6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "docker-sdk", + "name": "@docker/node-sdk", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "docker-sdk", + "name": "@docker/node-sdk", "version": "0.0.1", "license": "Apache-2.0", "dependencies": { @@ -13,6 +13,8 @@ }, "devDependencies": { "@openapitools/openapi-generator-cli": "^2.23.4", + "@types/node": "^24.5.2", + "@types/ssh2": "^1.15.5", "oxlint": "^1.16.0", "oxlint-tsgolint": "^0.2.0", "prettier": "^3.6.2", @@ -1399,17 +1401,42 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.5.1.tgz", - "integrity": "sha512-/SQdmUP2xa+1rdx7VwB9yPq8PaKej8TD5cQ+XfKDPWWC+VDJU4rvVVagXqKUzhKjtFoNA8rXDJAkCxQPAe00+Q==", + "version": "24.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.5.2.tgz", + "integrity": "sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ==", "dev": true, "license": "MIT", - "optional": true, - "peer": true, "dependencies": { "undici-types": "~7.12.0" } }, + "node_modules/@types/ssh2": { + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/@types/ssh2/-/ssh2-1.15.5.tgz", + "integrity": "sha512-N1ASjp/nXH3ovBHddRJpli4ozpk6UdDYIX4RJWFa9L1YKnzdhTlVmiGHm4DZnj/jLbqZpes4aeR30EFGQtvhQQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "^18.11.18" + } + }, + "node_modules/@types/ssh2/node_modules/@types/node": { + "version": "18.19.127", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.127.tgz", + "integrity": "sha512-gSjxjrnKXML/yo0BO099uPixMqfpJU0TKYjpfLU7TrtA2WWDki412Np/RSTPRil1saKBhvVVKzVx/p/6p94nVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/@types/ssh2/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "node_modules/@vitest/expect": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.4.tgz", @@ -4427,9 +4454,7 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.12.0.tgz", "integrity": "sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==", "dev": true, - "license": "MIT", - "optional": true, - "peer": true + "license": "MIT" }, "node_modules/universalify": { "version": "2.0.1", diff --git a/package.json b/package.json index e991fe0..04873e8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "type": "module", "license": "Apache-2.0", - "main": "dist/index.js", + "main": "dist/index.mjs", "types": "dist/index.d.ts", "exports": { ".": { @@ -45,15 +45,18 @@ "generate": "openapi-generator-cli generate -i swagger.yaml -c openapi-config.yaml -o lib && npm run format", "build": "npm run generate && tsup", "test": "vitest run", + "typecheck": "tsc --noEmit", "lint": "oxlint --type-aware", "format": "prettier --write .", - "check": "prettier --check ." + "format.check": "prettier --check ." }, "dependencies": { "ssh2": "^1.16.0" }, "devDependencies": { "@openapitools/openapi-generator-cli": "^2.23.4", + "@types/node": "^24.5.2", + "@types/ssh2": "^1.15.5", "oxlint": "^1.16.0", "oxlint-tsgolint": "^0.2.0", "prettier": "^3.6.2", @@ -66,4 +69,3 @@ }, "packageManager": "npm@10.9.3" } - diff --git a/templates/model/model.mustache b/templates/model/model.mustache index da40e05..ac1dd68 100644 --- a/templates/model/model.mustache +++ b/templates/model/model.mustache @@ -3,7 +3,7 @@ {{#models}} {{#model}} {{#tsImports}} -import { {{classname}} } from '{{filename}}{{importFileExtension}}'; +import { type {{classname}} } from '{{filename}}{{importFileExtension}}'; {{#-last}} {{/-last}} diff --git a/test-integration/cjs-project/.gitignore b/test-integration/cjs-project/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/test-integration/cjs-project/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json \ No newline at end of file diff --git a/test-integration/cjs-project/import.test.js b/test-integration/cjs-project/import.test.js new file mode 100644 index 0000000..fd609ef --- /dev/null +++ b/test-integration/cjs-project/import.test.js @@ -0,0 +1,8 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const { DockerClient } = require('@docker/node-sdk'); + +test('CJS import should work', () => { + assert.equal(typeof DockerClient, 'function'); + assert.equal(typeof DockerClient.fromDockerConfig, 'function'); +}); diff --git a/test-integration/cjs-project/package.json b/test-integration/cjs-project/package.json new file mode 100644 index 0000000..71b42bc --- /dev/null +++ b/test-integration/cjs-project/package.json @@ -0,0 +1,16 @@ +{ + "name": "cjs-project", + "version": "1.0.0", + "private": true, + "scripts": { + "test": "node --test" + }, + "type": "commonjs", + "dependencies": { + "@docker/node-sdk": "file:../.." + }, + "devDependencies": { + "typescript": "^5.9.2", + "vitest": "^3.2.4" + } +} diff --git a/test-integration/esm-project/.gitignore b/test-integration/esm-project/.gitignore new file mode 100644 index 0000000..25c8fdb --- /dev/null +++ b/test-integration/esm-project/.gitignore @@ -0,0 +1,2 @@ +node_modules +package-lock.json \ No newline at end of file diff --git a/test-integration/esm-project/import.test.ts b/test-integration/esm-project/import.test.ts new file mode 100644 index 0000000..c01b645 --- /dev/null +++ b/test-integration/esm-project/import.test.ts @@ -0,0 +1,9 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; + +import { DockerClient } from '@docker/node-sdk'; + +test('ES module import should work', () => { + assert.equal(typeof DockerClient, 'function'); + assert.equal(typeof DockerClient.fromDockerConfig, 'function'); +}); diff --git a/test-integration/esm-project/package.json b/test-integration/esm-project/package.json new file mode 100644 index 0000000..ab130ab --- /dev/null +++ b/test-integration/esm-project/package.json @@ -0,0 +1,16 @@ +{ + "name": "esm-project", + "version": "1.0.0", + "private": true, + "scripts": { + "test": "node --test" + }, + "type": "module", + "dependencies": { + "@docker/node-sdk": "file:../.." + }, + "devDependencies": { + "@types/node": "^24.5.2", + "typescript": "^5.9.2" + } +} diff --git a/test-integration/esm-project/tsconfig.json b/test-integration/esm-project/tsconfig.json new file mode 100644 index 0000000..45c26b8 --- /dev/null +++ b/test-integration/esm-project/tsconfig.json @@ -0,0 +1,44 @@ +{ + // Visit https://aka.ms/tsconfig to read more about this file + "compilerOptions": { + // File Layout + // "rootDir": "./src", + // "outDir": "./dist", + + // Environment Settings + // See also https://aka.ms/tsconfig/module + "module": "nodenext", + "target": "esnext", + "types": ["node"], + // For nodejs: + // "lib": ["esnext"], + // "types": ["node"], + // and npm install -D @types/node + + // Other Outputs + "sourceMap": true, + "declaration": true, + "declarationMap": true, + + // Stricter Typechecking Options + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + + // Style Options + // "noImplicitReturns": true, + // "noImplicitOverride": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + // "noFallthroughCasesInSwitch": true, + // "noPropertyAccessFromIndexSignature": true, + + // Recommended Options + "strict": true, + "jsx": "react-jsx", + "verbatimModuleSyntax": true, + "isolatedModules": true, + "noUncheckedSideEffectImports": true, + "moduleDetection": "force", + "skipLibCheck": true + } +} diff --git a/test/util.test.ts b/test/util.test.ts new file mode 100644 index 0000000..71f7df0 --- /dev/null +++ b/test/util.test.ts @@ -0,0 +1,147 @@ +import { assert, test, describe } from 'vitest'; +import { getErrorMessage } from '../lib/util.js'; + +describe('utils', () => { + describe('getErrorMessage', () => { + test('should return undefined for null', () => { + const result = getErrorMessage(null); + assert.isUndefined(result); + }); + + test('should return undefined for undefined', () => { + const result = getErrorMessage(undefined); + assert.isUndefined(result); + }); + + test('should return undefined for false', () => { + const result = getErrorMessage(false); + assert.isUndefined(result); + }); + + test('should return undefined for 0', () => { + const result = getErrorMessage(0); + assert.isUndefined(result); + }); + + test('should return undefined for empty string', () => { + const result = getErrorMessage(''); + assert.isUndefined(result); + }); + + test('should return string when input is a string', () => { + const result = getErrorMessage('error message'); + assert.equal(result, 'error message'); + }); + + test('should return Error message property', () => { + const error = new Error('test error'); + const result = getErrorMessage(error); + assert.equal(result, 'test error'); + }); + + test('should handle TypeError', () => { + const error = new TypeError('type error message'); + const result = getErrorMessage(error); + assert.equal(result, 'type error message'); + }); + + test('should handle custom Error subclass', () => { + class CustomError extends Error { + constructor(message: string) { + super(message); + this.name = 'CustomError'; + } + } + + const error = new CustomError('custom error message'); + const result = getErrorMessage(error); + assert.equal(result, 'custom error message'); + }); + + test('should extract message from object with message property', () => { + const errorObj = { message: 'nested error message' }; + const result = getErrorMessage(errorObj); + assert.equal(result, 'nested error message'); + }); + + test('should handle deeply nested message property', () => { + const errorObj = { message: { message: 'deeply nested error' } }; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + + test('should handle object with message property containing Error', () => { + const errorObj = { + message: new Error('error in message property'), + }; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + + test('should return undefined for object without message property', () => { + const obj = { code: 'ENOENT', path: '/some/path' }; + const result = getErrorMessage(obj); + assert.isUndefined(result); + }); + + test('should return undefined for number', () => { + const result = getErrorMessage(42); + assert.isUndefined(result); + }); + + test('should return undefined for boolean true', () => { + const result = getErrorMessage(true); + assert.isUndefined(result); + }); + + test('should return undefined for array', () => { + const result = getErrorMessage(['error', 'array']); + assert.isUndefined(result); + }); + + test('should handle circular reference in nested messages', () => { + const errorObj: any = { message: null }; + errorObj.message = errorObj; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + + test('should handle null message property', () => { + const errorObj = { message: null }; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + + test('should handle undefined message property', () => { + const errorObj = { message: undefined }; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + + test('should handle empty string message property', () => { + const errorObj = { message: '' }; + const result = getErrorMessage(errorObj); + assert.equal(result, ''); + }); + + test('should handle complex circular reference chain', () => { + const obj1: any = { message: null }; + const obj2: any = { message: null }; + obj1.message = obj2; + obj2.message = obj1; + const result = getErrorMessage(obj1); + assert.isUndefined(result); + }); + + test('should handle self-referencing object with other properties', () => { + const errorObj: any = { + code: 'ERROR', + timestamp: Date.now(), + message: null, + }; + errorObj.message = errorObj; + const result = getErrorMessage(errorObj); + assert.isUndefined(result); + }); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index fd3646a..11cb454 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,30 @@ { "compilerOptions": { - "target": "ES2015", - "moduleResolution": "nodenext" - } + "lib": ["ES2022"], + "strict": true, + "allowJs": true, + "esModuleInterop": true, + "skipLibCheck": true, + "moduleResolution": "NodeNext", + "module": "NodeNext", + "target": "ES2022", + "baseUrl": ".", + "noEmit": true, + "rootDir": "./lib", + "declaration": true, + "declarationMap": true, + "sourceMap": true, + "allowImportingTsExtensions": true, + "allowSyntheticDefaultImports": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "isolatedModules": true, + "removeComments": true, + "moduleDetection": "force", + "verbatimModuleSyntax": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true + }, + "include": ["lib/**/*"], + "exclude": ["dist", "node_modules"] } diff --git a/tsup.config.ts b/tsup.config.ts index 4bf9933..365cb80 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -4,7 +4,7 @@ export default defineConfig({ entry: ['lib/index.ts'], format: ['cjs', 'esm'], - dts: false, // disable dts generation for now to work through type issues + dts: true, minify: false, outDir: 'dist/', clean: true, diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..0ecc43c --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,11 @@ +/// +import { defineConfig } from 'vite'; + +export default defineConfig({ + test: { + exclude: [ + 'test-integration/cjs-project', + 'test-integration/esm-project', + ], + }, +});