Skip to content

Fixed package import issues#12

Merged
ndeloof merged 16 commits into
mainfrom
generate-type-defs-and-fix-package-import
Sep 24, 2025
Merged

Fixed package import issues#12
ndeloof merged 16 commits into
mainfrom
generate-type-defs-and-fix-package-import

Conversation

@wmluke

@wmluke wmluke commented Sep 23, 2025

Copy link
Copy Markdown
Contributor

What I did

Fixed issues importing from '@docker/node-sdk'

How I did it

  • Enabled DTS generation by fixing type errors
  • Fixed main reference in package.json
  • Use type imports in generated models
  • Also, updated jsdoc references

How to verify it

I created a playground project to import @docker/node-sdk and get running containers.

Human readable description for the release notes

Fixed package import issues

- Enabled DTS generation by fixing type errors
- Fixed `main` reference in package.json
- Use type imports in generated models
Also, updated jsdoc references
@wmluke wmluke requested a review from Copilot September 23, 2025 19:17
@wmluke wmluke self-assigned this Sep 23, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes package import issues for the @docker/node-sdk library by enabling TypeScript declaration file generation and resolving import-related problems.

  • Enabled DTS generation by fixing type errors and switching dts: false to dts: true
  • Fixed the main entry point in package.json to use the correct ESM extension
  • Updated all imports in generated models to use type-only imports for better performance

Reviewed Changes

Copilot reviewed 107 out of 109 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tsup.config.ts Enabled DTS generation by changing dts from false to true
package.json Fixed main entry point and added missing type dependencies
templates/model/model.mustache Updated template to generate type-only imports
lib/util.ts Added new utility functions for error handling and parsing
lib/http.ts Improved error handling and type safety
lib/docker-client.ts Enhanced error handling and refactored utility usage
lib/ssh.ts Fixed SSH method name from forwardInStreamLocal to forwardOutStreamLocal
lib/socket.ts Added proper type imports and improved callback signature
lib/tls.ts Updated to use new utility function for error message extraction
lib/models/*.ts Updated all model files to use type-only imports
test/util.test.ts Added comprehensive test coverage for utility functions
README.md Added installation instructions and import example

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread lib/ssh.ts

sshStream.emit('connect');
});
conn.openssh_forwardOutStreamLocal(

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method name appears to be incorrect. Based on the context of creating a Unix socket connection through SSH, this should likely be openssh_forwardInStreamLocal rather than openssh_forwardOutStreamLocal. The 'In' variant is typically used for incoming connections to local sockets.

Suggested change
conn.openssh_forwardOutStreamLocal(
conn.openssh_forwardInStreamLocal(

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndeloof heads up: i switched to openssh_forwardOutStreamLocal b/c conn.openssh_forwardInStreamLocal had type errors b/c the callback does not have a stream parameter. openssh_forwardOutStreamLocal does pass stream in the callback.

Comment thread lib/socket.ts
const onError = (error: Error) => {
socket.removeListener('connect', onConnect);
callback(error);
callback(error, socket);

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The callback is being called with both an error and a socket parameter even when there's an error. According to Node.js callback conventions, when an error occurs, the second parameter should typically be undefined or omitted. Consider calling callback(error) instead.

Suggested change
callback(error, socket);
callback(error);

Copilot uses AI. Check for mistakes.
Comment thread lib/docker-client.ts
@@ -177,13 +177,12 @@ export class DockerClient {
}
} catch (parseError) {
// Skip invalid meta.json files

Copilot AI Sep 23, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The continue statement was removed but the comment suggests skipping invalid files. Either the continue statement should be restored, or the comment should be updated to reflect the new behavior of not skipping invalid files.

Suggested change
// Skip invalid meta.json files
// Ignore invalid meta.json files

Copilot uses AI. Check for mistakes.
@wmluke wmluke requested a review from ndeloof September 23, 2025 19:36
- Configured separate projects for ESM (`esm-project`) and CJS (`cjs-project`) compatibility testing.
- Updated CI workflow to include integration tests for both formats.
- Added `.gitignore` files to exclude `node_modules` and lockfiles in test projects.
- Verified `DockerClient` imports and functionality for both module types.
@ndeloof ndeloof merged commit 67454b0 into main Sep 24, 2025
4 checks passed
@ndeloof ndeloof deleted the generate-type-defs-and-fix-package-import branch September 24, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants