Skip to content

Refactor client-node encoder to use symbolic link for client-common imports#626

Open
Claude wants to merge 3 commits into
mainfrom
claude/refactor-client-node-imports
Open

Refactor client-node encoder to use symbolic link for client-common imports#626
Claude wants to merge 3 commits into
mainfrom
claude/refactor-client-node-imports

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 17, 2026

Summary

Demonstrates a monorepo optimization pattern by refactoring packages/client-node/src/utils/encoder.ts to import from client-common source via symbolic link instead of the published package.

Changes

  • Added symbolic link: packages/client-node/src/common../../client-common/src
  • Refactored imports in encoder.ts: Changed from package imports to relative paths through symlink:
    // Before
    import type { DataFormat, InsertValues, JSONHandling, ValuesEncoder } from '@clickhouse/client-common'
    
    // After
    import type { DataFormat } from '../common/data_formatter/formatter'
    import type { InsertValues } from '../common/clickhouse_types'
    import type { JSONHandling } from '../common/parse/json_handling'
    import type { ValuesEncoder } from '../common/config'

This approach provides direct source access during development, improves IDE navigation, and reduces rebuild cycles. The encoder.ts module (86 lines, mid-sized) was selected as a reference implementation with focused scope: 5 type imports, 2 function imports.

Checklist

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@Claude Claude AI requested review from Copilot and removed request for Copilot March 17, 2026 08:38
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 17, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ peter-leonov-ch
❌ Claude
You have signed the CLA already but the status is still pending? Let us recheck it.

Co-authored-by: peter-leonov-ch <209667683+peter-leonov-ch@users.noreply.github.com>
@Claude Claude AI requested review from Copilot and removed request for Copilot March 17, 2026 08:45
@Claude Claude AI changed the title [WIP] Refactor imports in client-node using symbolic link Refactor client-node encoder to use symbolic link for client-common imports Mar 17, 2026
@Claude Claude AI requested a review from peter-leonov-ch March 17, 2026 08:46
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@peter-leonov-ch peter-leonov-ch marked this pull request as ready for review March 23, 2026 20:41
Copilot AI review requested due to automatic review settings March 23, 2026 20:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors client-node’s encoder to consume client-common source via a symlinked directory, aiming to improve local development ergonomics (IDE navigation, fewer rebuilds).

Changes:

  • Swapped @clickhouse/client-common imports in encoder.ts to relative imports through src/common (symlink target).
  • Added packages/client-node/src/common link pointing to ../../client-common/src.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/client-node/src/utils/encoder.ts Replaces package-based imports with symlink-based relative imports to client-common source modules.
packages/client-node/src/common Introduces the symlink target path for client-common/src within client-node/src.
Comments suppressed due to low confidence (1)

packages/client-node/src/common:1

  • This change relies on packages/client-node/src/common being a real symlink. On platforms/environments where symlinks are disabled (notably Windows with core.symlinks=false, some CI tarball checkouts, or certain package install flows), this can materialize as a plain text file instead of a directory, which will break module resolution for imports like ../common/.... Consider replacing this with a TypeScript paths mapping (and matching bundler config), or ensure the repo/tooling enforces symlink support (e.g., documented setup + CI validation) so checkouts fail fast when symlinks aren’t honored.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +5 to +8
import {
encodeJSON,
isSupportedRawFormat,
} from '../common/data_formatter/formatter'
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

Importing from a symlinked path that points outside the client-node package can break packaging/publishing: many npm/pack workflows either (a) don’t include symlink targets, (b) rewrite symlinks, or (c) disallow following symlinks outside the package root. That can cause the built artifact (or published package) to have unresolved imports at runtime/build time. If the intent is dev-only, consider gating this behind a build-time alias (tsconfig paths + bundler/tsc transform) so published artifacts still resolve from @clickhouse/client-common, or add a prepack step that vendors/rewrites the imports to in-package files.

Suggested change
import {
encodeJSON,
isSupportedRawFormat,
} from '../common/data_formatter/formatter'
import { encodeJSON, isSupportedRawFormat } from '@clickhouse/client-common'

Copilot uses AI. Check for mistakes.
ValuesEncoder,
} from '@clickhouse/client-common'
import { encodeJSON, isSupportedRawFormat } from '@clickhouse/client-common'
import type { DataFormat } from '../common/data_formatter/formatter'
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

The PR description checklist states that unit/integration tests were added, but the provided diff only changes imports and adds the symlink. If tests were added elsewhere, consider including them in the PR (or updating the checklist/description) so the claim matches the actual changes under review.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +5
import type { DataFormat } from '../common/data_formatter/formatter'
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'
import {
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

These imports come from the same module path, which increases duplication and makes future refactors noisier. Consider consolidating into a single import using an inline type import (e.g., importing type DataFormat alongside the value imports) to keep the module reference in one place.

Suggested change
import type { DataFormat } from '../common/data_formatter/formatter'
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'
import {
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'
import {
type DataFormat,

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +8
import type { DataFormat } from '../common/data_formatter/formatter'
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'
import {
encodeJSON,
isSupportedRawFormat,
} from '../common/data_formatter/formatter'
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

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

These imports come from the same module path, which increases duplication and makes future refactors noisier. Consider consolidating into a single import using an inline type import (e.g., importing type DataFormat alongside the value imports) to keep the module reference in one place.

Suggested change
import type { DataFormat } from '../common/data_formatter/formatter'
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'
import {
encodeJSON,
isSupportedRawFormat,
} from '../common/data_formatter/formatter'
import { type DataFormat, encodeJSON, isSupportedRawFormat } from '../common/data_formatter/formatter'
import type { InsertValues } from '../common/clickhouse_types'
import type { JSONHandling } from '../common/parse/json_handling'
import type { ValuesEncoder } from '../common/config'

Copilot uses AI. Check for mistakes.
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.

4 participants