Skip to content

Commit b32a283

Browse files
Add the Zerobus Typescript SDK (#2)
* Initial commit Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Change env var names Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix READMEs Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix Rust version Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Add table definition in example/README.md Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix unit test import Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Better output message for integration tests missing env vars Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix CI Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix runners Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Commit package-lock.json Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix CI runners attempt 2 Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Fix runners attempt 3 Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Attempt 4 Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> * Remove MacOS from CI Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com> --------- Signed-off-by: teodordelibasic-db <teodor.delibasic@databricks.com>
1 parent d86f22a commit b32a283

30 files changed

+8635
-1
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature or improvement for the TypeScript SDK for Zerobus.
4+
title: "[FEATURE] "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Problem Statement**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Proposed Solution**
14+
A clear and concise description of what you want to happen.
15+
16+
**Additional Context**
17+
Add any other context, references or screenshots about the feature request here.

.github/ISSUE_TEMPLATE/issue.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: SDK Issue
3+
about: Use this to report an issue with the TypeScript SDK for Zerobus.
4+
title: "[ISSUE] "
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Description**
11+
A clear and concise description of what the bug is.
12+
13+
**Reproduction**
14+
A minimal code sample demonstrating the bug.
15+
16+
**Expected behavior**
17+
A clear and concise description of what you expected to happen.
18+
19+
**Is it a regression?**
20+
Did this work in a previous version of the SDK? If so, which versions did you try?
21+
22+
**Debug Logs**
23+
Include any error messages or stack traces here.
24+
25+
**Other Information**
26+
- OS: [e.g. macOS, Linux, Windows]
27+
- Node.js Version: [e.g. 18.x, 20.x]
28+
- SDK Version: [e.g. 0.0.1]
29+
30+
**Additional context**
31+
Add any other context about the problem here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## What changes are proposed in this pull request?
2+
3+
Provide the readers and reviewers with the information they need to understand
4+
this PR in a comprehensive manner.
5+
6+
Specifically, try to answer the two following questions:
7+
8+
- **WHAT** changes are being made in the PR? This should be a summary of the
9+
major changes to allow the reader to quickly understand the PR without having
10+
to look at the code.
11+
- **WHY** are these changes needed? This should provide the context that the
12+
reader might be missing. For example, were there any decisions behind the
13+
change that are not reflected in the code itself?
14+
15+
The "why part" is the most important of the two as it usually cannot be
16+
inferred from the code itself. A well-written PR description will help future
17+
developers (including your future self) to know how to interact and update your
18+
code.
19+
20+
## How is this tested?
21+
22+
Describe any tests you have done; especially if test tests are not part of
23+
the unit tests (e.g. local tests).
24+
25+
**ALWAYS ANSWER THIS QUESTION:** Answer with "N/A" if tests are not applicable
26+
to your PR (e.g. if the PR only modifies comments). Do not be afraid of
27+
answering "Not tested" if the PR has not been tested. Being clear about what
28+
has been done and not done provides important context to the reviewers.

.github/workflows/ci.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
10+
jobs:
11+
build:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
settings:
16+
- host: linux-ubuntu-latest
17+
target: x86_64-unknown-linux-gnu
18+
- host: linux-ubuntu-latest
19+
target: aarch64-unknown-linux-gnu
20+
- host: windows-server-latest
21+
target: x86_64-pc-windows-msvc
22+
23+
name: Build - ${{ matrix.settings.target }}
24+
runs-on:
25+
group: databricks-protected-runner-group
26+
labels: ${{ matrix.settings.host }}
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: 20
35+
cache: 'npm'
36+
37+
- name: Install Rust (Unix)
38+
if: runner.os != 'Windows'
39+
run: |
40+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
41+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
42+
43+
- name: Install Rust (Windows)
44+
if: runner.os == 'Windows'
45+
run: |
46+
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
47+
.\rustup-init.exe -y --default-toolchain stable
48+
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
49+
shell: powershell
50+
51+
- name: Add Rust target
52+
run: rustup target add ${{ matrix.settings.target }}
53+
54+
- name: Cache cargo
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/.cargo/registry/index/
59+
~/.cargo/registry/cache/
60+
~/.cargo/git/db/
61+
target/
62+
key: ${{ matrix.settings.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
63+
64+
- name: Install cross-compilation tools (Linux ARM64)
65+
if: matrix.settings.target == 'aarch64-unknown-linux-gnu'
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
69+
70+
- name: Install dependencies
71+
run: npm ci
72+
73+
- name: Build
74+
run: npm run build -- --target ${{ matrix.settings.target }}
75+
env:
76+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
77+
78+
- name: Upload artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: bindings-${{ matrix.settings.target }}
82+
path: '*.node'
83+
if-no-files-found: error
84+
85+
test:
86+
name: Test Node.js ${{ matrix.node }} - ${{ matrix.os }}
87+
runs-on:
88+
group: databricks-protected-runner-group
89+
labels: ${{ matrix.os }}
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
os: [linux-ubuntu-latest, windows-server-latest]
94+
node: ['16', '18', '20']
95+
96+
steps:
97+
- uses: actions/checkout@v4
98+
99+
- name: Setup Node.js ${{ matrix.node }}
100+
uses: actions/setup-node@v4
101+
with:
102+
node-version: ${{ matrix.node }}
103+
cache: 'npm'
104+
105+
- name: Install Rust (Unix)
106+
if: runner.os != 'Windows'
107+
run: |
108+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
109+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
110+
111+
- name: Install Rust (Windows)
112+
if: runner.os == 'Windows'
113+
run: |
114+
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
115+
.\rustup-init.exe -y --default-toolchain stable
116+
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
117+
shell: powershell
118+
119+
- name: Install dependencies
120+
run: npm ci
121+
122+
- name: Build
123+
run: npm run build:debug
124+
125+
- name: Test
126+
run: npm test
127+
if: matrix.os != 'windows-server-latest'

.github/workflows/publish.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
settings:
13+
- host: macos-latest
14+
target: x86_64-apple-darwin
15+
- host: macos-latest
16+
target: aarch64-apple-darwin
17+
- host: linux-ubuntu-latest
18+
target: x86_64-unknown-linux-gnu
19+
- host: linux-ubuntu-latest
20+
target: aarch64-unknown-linux-gnu
21+
- host: windows-server-latest
22+
target: x86_64-pc-windows-msvc
23+
24+
name: Build - ${{ matrix.settings.target }}
25+
runs-on:
26+
group: databricks-protected-runner-group
27+
labels: ${{ matrix.settings.host }}
28+
29+
steps:
30+
- uses: actions/checkout@v4
31+
32+
- name: Setup Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: 20
36+
registry-url: 'https://registry.npmjs.org'
37+
38+
- name: Install Rust (Unix)
39+
if: runner.os != 'Windows'
40+
run: |
41+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
42+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
43+
44+
- name: Install Rust (Windows)
45+
if: runner.os == 'Windows'
46+
run: |
47+
Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe
48+
.\rustup-init.exe -y --default-toolchain stable
49+
echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
50+
shell: powershell
51+
52+
- name: Add Rust target
53+
run: rustup target add ${{ matrix.settings.target }}
54+
55+
- name: Install cross-compilation tools (Linux ARM64)
56+
if: matrix.settings.target == 'aarch64-unknown-linux-gnu'
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
60+
61+
- name: Install dependencies
62+
run: npm ci
63+
64+
- name: Build
65+
run: npm run build -- --target ${{ matrix.settings.target }}
66+
env:
67+
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
68+
69+
- name: Upload artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: bindings-${{ matrix.settings.target }}
73+
path: '*.node'
74+
if-no-files-found: error
75+
76+
publish:
77+
name: Publish to NPM
78+
runs-on:
79+
group: databricks-protected-runner-group
80+
labels: linux-ubuntu-latest
81+
needs: build
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Setup Node.js
87+
uses: actions/setup-node@v4
88+
with:
89+
node-version: 20
90+
registry-url: 'https://registry.npmjs.org'
91+
92+
- name: Install dependencies
93+
run: npm ci
94+
95+
- name: Download all artifacts
96+
uses: actions/download-artifact@v4
97+
with:
98+
path: artifacts
99+
100+
- name: Move artifacts
101+
run: npm run artifacts
102+
103+
- name: List packages
104+
run: ls -R ./npm
105+
106+
- name: Publish
107+
run: npm publish --access public
108+
env:
109+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Build artifacts
2+
target/
3+
*.node
4+
index.js
5+
index.d.ts
6+
7+
# Dependencies
8+
node_modules/
9+
npm-debug.log*
10+
yarn-debug.log*
11+
yarn-error.log*
12+
pnpm-debug.log*
13+
14+
# IDE
15+
.vscode/
16+
.idea/
17+
*.swp
18+
*.swo
19+
*~
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Environment
26+
.env
27+
.env.local
28+
.env.*.local
29+
30+
# Distribution
31+
dist/
32+
*.tgz
33+
34+
# Test coverage
35+
coverage/
36+
.nyc_output/
37+
38+
# Temporary files
39+
*.tmp
40+
*.temp
41+
.env
42+
43+
# Generated files
44+
examples/generated/
45+
schemas/*.pb
46+
schemas/*.b64

0 commit comments

Comments
 (0)