Skip to content

Commit 287977a

Browse files
Merge pull request #896 from ClickHouse/main
1.23 beta4
2 parents fae5998 + c85f066 commit 287977a

422 files changed

Lines changed: 2850 additions & 835 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
name: "publish: datatype parser"
2+
3+
# Independent publish + release for the standalone @clickhouse/datatype-parser
4+
# package (the data-type string parser). It is NOT part of the npm workspace
5+
# lockstep release driven by publish.yml — it carries its own version in
6+
# packages/datatype-parser/package.json and ships on its own cadence. Triggered
7+
# manually, and — like publish.yml — must be dispatched from the `release`
8+
# branch: the npm-publish environment is protected so only that branch may
9+
# deploy (the repo's human-in-the-loop release gate). Dispatches from any other
10+
# ref are skipped by the job-level `if` guard below.
11+
#
12+
# The release branch is itself protected, so the unit suite is not re-run here.
13+
# The `publish` job instead builds, packs the tarball, installs that exact
14+
# tarball into a throwaway project and smoke-tests its imports, and only then
15+
# publishes the same tarball with the "latest" tag (npm OIDC + provenance) and
16+
# pushes a matching git tag. The `e2e` job then repeats the smoke test against
17+
# the freshly published version on the registry across the supported Node
18+
# versions.
19+
20+
permissions:
21+
contents: read
22+
id-token: write # Required for npm OIDC authentication and provenance
23+
24+
concurrency:
25+
group: ${{ github.workflow }}
26+
cancel-in-progress: false
27+
28+
on:
29+
workflow_dispatch:
30+
31+
jobs:
32+
publish:
33+
# The npm-publish environment only permits the release branch to deploy;
34+
# skip cleanly on any other ref instead of failing the protection check.
35+
if: github.ref == 'refs/heads/release'
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 10
38+
environment: npm-publish
39+
permissions:
40+
contents: write # Required to push the release git tag
41+
id-token: write # Required for npm OIDC authentication and provenance
42+
defaults:
43+
run:
44+
working-directory: packages/datatype-parser
45+
outputs:
46+
version: ${{ steps.version.outputs.version }}
47+
steps:
48+
- name: Checkout repository
49+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
50+
51+
- name: Setup Node.js
52+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
53+
with:
54+
node-version: 24
55+
registry-url: "https://registry.npmjs.org"
56+
57+
- name: Install dependencies
58+
run: npm ci
59+
60+
- name: Build
61+
run: npm run build
62+
63+
- name: Get the release version
64+
id: version
65+
run: |
66+
VERSION=$(node -p "require('./package.json').version")
67+
echo "Publishing @clickhouse/datatype-parser@$VERSION"
68+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
69+
70+
- name: Pack the tarball
71+
id: pack
72+
# prepack rebuilds dist before packing.
73+
run: |
74+
set -euo pipefail
75+
TARBALL=$(npm pack --pack-destination "$RUNNER_TEMP" | tail -1)
76+
echo "Packed: $TARBALL"
77+
echo "tarball=$RUNNER_TEMP/$TARBALL" >> "$GITHUB_OUTPUT"
78+
79+
- name: Pre-publish smoke test (install the packed tarball)
80+
env:
81+
TARBALL: ${{ steps.pack.outputs.tarball }}
82+
run: |
83+
set -euo pipefail
84+
work="$(mktemp -d)"
85+
cd "$work"
86+
npm init -y >/dev/null 2>&1
87+
npm install "$TARBALL"
88+
# Verify the main barrel entry resolves and exposes the parser, from
89+
# the exact artifact we are about to publish.
90+
node --input-type=module -e "
91+
import * as dt from '@clickhouse/datatype-parser';
92+
if (typeof dt.parseDataType !== 'function') throw new Error('parseDataType missing from main export');
93+
console.log('OK: packed tarball imports cleanly');
94+
"
95+
96+
- name: Publish to npm
97+
# Publish the exact tarball that passed the pre-publish smoke test.
98+
env:
99+
TARBALL: ${{ steps.pack.outputs.tarball }}
100+
run: npm publish "$TARBALL" --access public --provenance
101+
102+
- name: Create and push release git tag
103+
env:
104+
RELEASE_TAG: datatype-parser-v${{ steps.version.outputs.version }}
105+
RELEASE_VERSION: ${{ steps.version.outputs.version }}
106+
run: |
107+
if git ls-remote --exit-code --tags origin "refs/tags/${RELEASE_TAG}" >/dev/null 2>&1; then
108+
echo "Tag ${RELEASE_TAG} already exists on origin; skipping."
109+
exit 0
110+
fi
111+
git config user.name "github-actions[bot]"
112+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
113+
git tag -a "${RELEASE_TAG}" -m "Release @clickhouse/datatype-parser ${RELEASE_VERSION}"
114+
git push origin "refs/tags/${RELEASE_TAG}"
115+
116+
e2e:
117+
name: e2e (node ${{ matrix.node }})
118+
needs: publish
119+
if: needs.publish.result == 'success'
120+
runs-on: ubuntu-latest
121+
timeout-minutes: 10
122+
strategy:
123+
fail-fast: true
124+
matrix:
125+
node: [20, 22, 24]
126+
env:
127+
PUBLISHED_VERSION: ${{ needs.publish.outputs.version }}
128+
steps:
129+
- name: Setup NodeJS ${{ matrix.node }}
130+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
131+
with:
132+
node-version: ${{ matrix.node }}
133+
registry-url: "https://registry.npmjs.org"
134+
135+
- name: Wait for @clickhouse/datatype-parser@${{ needs.publish.outputs.version }} on npm
136+
run: |
137+
set -euo pipefail
138+
if [ -z "${PUBLISHED_VERSION}" ]; then
139+
echo "PUBLISHED_VERSION is empty; cannot wait for npm publication." >&2
140+
exit 1
141+
fi
142+
pkg="@clickhouse/datatype-parser"
143+
# Poll the registry for up to ~5 minutes. New versions usually surface
144+
# in seconds, but the registry CDN can lag.
145+
max_attempts=60
146+
sleep_seconds=5
147+
attempt=1
148+
echo "Waiting for ${pkg}@${PUBLISHED_VERSION} to be available on npm..."
149+
while true; do
150+
if npm view "${pkg}@${PUBLISHED_VERSION}" version >/dev/null 2>&1; then
151+
echo " ${pkg}@${PUBLISHED_VERSION} is available."
152+
break
153+
fi
154+
if [ "$attempt" -ge "$max_attempts" ]; then
155+
echo "Timed out waiting for ${pkg}@${PUBLISHED_VERSION} on npm" >&2
156+
exit 1
157+
fi
158+
echo " attempt ${attempt}/${max_attempts}: not available yet, sleeping ${sleep_seconds}s..."
159+
attempt=$((attempt + 1))
160+
sleep "$sleep_seconds"
161+
done
162+
163+
- name: Install and import the published package
164+
run: |
165+
set -euo pipefail
166+
work="$(mktemp -d)"
167+
cd "$work"
168+
npm init -y >/dev/null 2>&1
169+
npm install "@clickhouse/datatype-parser@${PUBLISHED_VERSION}"
170+
# Verify the main barrel entry resolves and exposes the parser to a
171+
# downstream consumer.
172+
node --input-type=module -e "
173+
import * as dt from '@clickhouse/datatype-parser';
174+
if (typeof dt.parseDataType !== 'function') throw new Error('parseDataType missing from main export');
175+
console.log('OK: @clickhouse/datatype-parser@${PUBLISHED_VERSION} imports cleanly');
176+
"

.github/workflows/tests-skill-rowbinary-parser.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ on:
99
paths:
1010
- .github/workflows/tests-skill-rowbinary-parser.yml
1111
- skills/clickhouse-js-node-rowbinary-parser/**
12+
# The skill depends on @clickhouse/datatype-parser; rerun against local
13+
# parser changes so a parser regression cannot pass this suite unnoticed.
14+
- packages/datatype-parser/**
1215
pull_request:
1316
paths:
1417
- .github/workflows/tests-skill-rowbinary-parser.yml
1518
- skills/clickhouse-js-node-rowbinary-parser/**
19+
- packages/datatype-parser/**
1620

1721
concurrency:
1822
group: "${{ github.workflow }}-${{ github.ref }}"
@@ -33,9 +37,22 @@ jobs:
3337
with:
3438
node-version: 24
3539

40+
# Build + pack the in-repo @clickhouse/datatype-parser so the skill is
41+
# exercised against THIS checkout, not the version published to npm. The
42+
# committed package.json keeps a published range for end users; we only
43+
# override node_modules below (`npm install <tarball> --no-save`).
44+
- name: Pack local @clickhouse/datatype-parser
45+
working-directory: ${{ github.workspace }}
46+
run: |
47+
npm ci
48+
npm pack --workspace @clickhouse/datatype-parser --pack-destination "${{ runner.temp }}"
49+
3650
- name: Install dependencies
3751
run: npm ci
3852

53+
- name: Use the local datatype-parser build
54+
run: npm install "${{ runner.temp }}"/clickhouse-datatype-parser-*.tgz --no-save
55+
3956
- name: Typecheck
4057
run: npm run typecheck
4158

@@ -68,8 +85,21 @@ jobs:
6885
with:
6986
node-version: ${{ matrix.node }}
7087

88+
# Build + pack the in-repo @clickhouse/datatype-parser so the skill is
89+
# exercised against THIS checkout, not the version published to npm. The
90+
# committed package.json keeps a published range for end users; we only
91+
# override node_modules below (`npm install <tarball> --no-save`).
92+
- name: Pack local @clickhouse/datatype-parser
93+
working-directory: ${{ github.workspace }}
94+
run: |
95+
npm ci
96+
npm pack --workspace @clickhouse/datatype-parser --pack-destination "${{ runner.temp }}"
97+
7198
- name: Install dependencies
7299
run: npm ci
73100

101+
- name: Use the local datatype-parser build
102+
run: npm install "${{ runner.temp }}"/clickhouse-datatype-parser-*.tgz --no-save
103+
74104
- name: Run unit tests
75105
run: npm test

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
- The `@clickhouse/client-common` package is deprecated. `@clickhouse/client` (Node.js) and `@clickhouse/client-web` (Web) no longer depend on it; the shared code is now bundled into each client package. Everything previously importable from `@clickhouse/client-common` should be imported from `@clickhouse/client` or `@clickhouse/client-web` instead. The `@clickhouse/client-common` package itself will no longer receive updates. ([#845])
66

7+
- The `parseColumnType` function and its `SimpleColumnTypes` companion (exported from `@clickhouse/client`, `@clickhouse/client-web`, and `@clickhouse/client-common`) are deprecated and slated for removal in a future major version. They are superseded by the new standalone [`@clickhouse/datatype-parser`](https://www.npmjs.com/package/@clickhouse/datatype-parser) package (`parseDataType` plus its `Node` AST), which parses the full ClickHouse data-type grammar and emits an AST that mirrors the server's. ([#893])
8+
79
## New features
810

911
- (Node.js) Added a RowBinary reader library and agent skill under [`skills/clickhouse-js-node-rowbinary-parser`](./skills/clickhouse-js-node-rowbinary-parser). It ships type-specific, monomorphizable building blocks for decoding `RowBinary` / `RowBinaryWithNames` / `RowBinaryWithNamesAndTypes` streams (full-buffer and chunked), plus a skill that guides an agent to generate bespoke high-performance parsers from a query's column types. The skill is bundled into `@clickhouse/client` (registered in `agents.skills`) and is also published independently as the [`@clickhouse/rowbinary`](https://www.npmjs.com/package/@clickhouse/rowbinary) package. A matching RowBinary writer is planned. ([#864])
1012

13+
- Published the [`@clickhouse/datatype-parser`](https://www.npmjs.com/package/@clickhouse/datatype-parser) package: a small, dependency-free standalone parser for ClickHouse data-type strings (the kind sent in the types row of `RowBinaryWithNamesAndTypes`, e.g. `Array(Nullable(UInt64))`, `Tuple(a UInt8, b String)`, `Enum8('a' = 1)`). It is a faithful port of the server's `ParserDataType` and emits a JSON AST that is byte-identical to the server's `EXPLAIN AST json = 1` data-type subtree. It supersedes the deprecated `parseColumnType` (see Migration Notes). ([#893])
14+
1115
- (Node.js, `@experimental`) Added an additive `connection?: Connection<Stream.Readable>` option to `createClient` that lets a caller plug an externally-built backend `Connection`-like object in place of the default HTTP(S) factory. Only supposed to be used for testing the `chDB` integration. ([#879])
1216

1317
- Added `ClickHouseSettingsInterface`, a package-neutral structural counterpart to `ClickHouseSettings`, exported from `@clickhouse/client`, `@clickhouse/client-web`, and `@clickhouse/client-common`. It is identical to `ClickHouseSettings` except that its index signature omits `SettingsMap` (a class with a private member, which TypeScript compares nominally). Because each client package now bundles its own copy of the common module, their `ClickHouseSettings` types are mutually unassignable; `ClickHouseSettingsInterface` is structurally identical across all three packages and assignable into each package's `ClickHouseSettings`, so a consumer that shares a single settings-producing helper across both the Node.js and Web clients can type it against this one type without casts. Values typed as `SettingsMap` cannot be carried through it — use `ClickHouseSettings` if you need them. ([#889])
@@ -81,6 +85,7 @@ await client.query({
8185
[#845]: https://github.com/ClickHouse/clickhouse-js/pull/845
8286
[#864]: https://github.com/ClickHouse/clickhouse-js/pull/864
8387
[#889]: https://github.com/ClickHouse/clickhouse-js/pull/889
88+
[#893]: https://github.com/ClickHouse/clickhouse-js/pull/893
8489

8590
## Bug Fixes
8691

0 commit comments

Comments
 (0)