Skip to content

Commit 88dc369

Browse files
bfopsdrogusjdetterNateTheDev1dbrinkmanncw
authored
Import TypeScript SDK repo (#2941)
Co-authored-by: Piotr Sarnacki <drogus@gmail.com> Co-authored-by: John <no-reply@boppygames.gg> Co-authored-by: NateTheDev1 <nthnlrichards@gmail.com> Co-authored-by: Nathaniel Richards <46858886+NateTheDev1@users.noreply.github.com> Co-authored-by: dbrinkmanncw <109690865+dbrinkmanncw@users.noreply.github.com> Co-authored-by: Derek Brinkmann <dbrinkmann@citadelstudios.net> Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com> Co-authored-by: Mario Montoya <mamcx@elmalabarista.com> Co-authored-by: Kamil Jakubus <kamil.jakubus@usagi.coffee> Co-authored-by: Derek Brinkmann <dbrinkmann@clockworklabs.io> Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org> Co-authored-by: HSReina <hontoshadow@shadosoft-tm.com> Co-authored-by: Gérald Divoux <gerald.divoux@ninsight.io> Co-authored-by: Zeke Foppa <github.com/bfops> Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com> Co-authored-by: Halu <35203441+tcardlab@users.noreply.github.com> Co-authored-by: Puru Vijay <47742487+PuruVJ@users.noreply.github.com> Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com> Co-authored-by: Puru Vijay <awesomepuruvj@gmail.com> Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: james gilles <jameshgilles@gmail.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> Co-authored-by: Noa <coolreader18@gmail.com> Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com> Co-authored-by: Bastian Ganze <bastianganze@gmail.com> Co-authored-by: ChaseLewis <ChaseRLewis73003@gmail.com> Co-authored-by: DeveloperChaseLewis <developer.chase.lewis@gmail.com> Co-authored-by: Chip <36650721+Lethalchip@users.noreply.github.com> Co-authored-by: Julien Lavocat <julien.lavocat@gmail.com>
2 parents f2c8c6d + 5ab01b2 commit 88dc369

File tree

151 files changed

+18432
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+18432
-0
lines changed

sdks/typescript/.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "clockworklabs/spacetimedb-typescript-sdk" }
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "public",
11+
"baseBranch": "main",
12+
"updateInternalDependencies": "patch",
13+
"ignore": []
14+
}

sdks/typescript/.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/client_api/*.ts linguist-generated=true
2+
examples/quickstart/client/src/module_bindings/*.ts linguist-generated=true
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Description of Changes
2+
3+
_Describe what has been changed, any new features or bug fixes_
4+
5+
## API
6+
7+
- [ ] This is an API breaking change to the SDK
8+
9+
_If the API is breaking, please state below what will break_
10+
11+
## Requires SpacetimeDB PRs
12+
13+
_List any PRs here that are required for this SDK change to work_
14+
15+
## Testing
16+
17+
_Write instructions for a test that you performed for this PR_
18+
19+
- [ ] Describe a test for this PR that you have completed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
master
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Continuous Releases
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: 18
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9.7
18+
run_install: true
19+
20+
- name: Build
21+
run: pnpm compile
22+
23+
- name: Release
24+
run: cd packages/sdk && pnpm dlx pkg-pr-new publish --compact --pnpm
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18
21+
22+
- uses: pnpm/action-setup@v4
23+
with:
24+
version: 9.7
25+
run_install: true
26+
27+
- name: Get pnpm store directory
28+
shell: bash
29+
run: |
30+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
31+
32+
- uses: actions/cache@v4
33+
name: Setup pnpm cache
34+
with:
35+
path: ${{ env.STORE_PATH }}
36+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
37+
restore-keys: |
38+
${{ runner.os }}-pnpm-store-
39+
40+
- name: Lint
41+
run: pnpm lint
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish
2+
on:
3+
push:
4+
branches:
5+
- 'main'
6+
7+
concurrency: ${{ github.workflow }}-${{ github.ref }}
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
id-token: write
14+
contents: write
15+
packages: write
16+
pull-requests: write
17+
issues: read
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: pnpm/action-setup@v4
22+
with:
23+
version: 9.7
24+
run_install: true
25+
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 18.x
29+
cache: 'pnpm'
30+
31+
- run: pnpm compile
32+
33+
- name: Create Release Pull Request or Publish
34+
id: changesets
35+
uses: changesets/action@v1
36+
with:
37+
publish: pnpm run ci:release
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
10+
jobs:
11+
compile-and-test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 18
22+
23+
- uses: pnpm/action-setup@v4
24+
with:
25+
version: 9.7
26+
run_install: true
27+
28+
- name: Get pnpm store directory
29+
shell: bash
30+
run: |
31+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
32+
33+
- uses: actions/cache@v4
34+
name: Setup pnpm cache
35+
with:
36+
path: ${{ env.STORE_PATH }}
37+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
38+
restore-keys: |
39+
${{ runner.os }}-pnpm-store-
40+
41+
- name: Compile
42+
run: pnpm compile
43+
44+
- name: Run sdk tests
45+
working-directory: packages/sdk
46+
run: pnpm test
47+
48+
# - name: Extract SpacetimeDB branch name from file
49+
# id: extract-branch
50+
# run: |
51+
# # Define the path to the branch file
52+
# BRANCH_FILE=".github/spacetimedb-branch.txt"
53+
54+
# # Default to master if file doesn't exist
55+
# if [ ! -f "$BRANCH_FILE" ]; then
56+
# echo "::notice::No SpacetimeDB branch file found, using 'master'"
57+
# echo "branch=master" >> $GITHUB_OUTPUT
58+
# exit 0
59+
# fi
60+
61+
# # Read and trim whitespace from the file
62+
# branch=$(cat "$BRANCH_FILE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
63+
64+
# # Fallback to master if empty
65+
# if [ -z "$branch" ]; then
66+
# echo "::warning::SpacetimeDB branch file is empty, using 'master'"
67+
# branch="master"
68+
# fi
69+
70+
# echo "branch=$branch" >> $GITHUB_OUTPUT
71+
# echo "Using SpacetimeDB branch from file: $branch"
72+
73+
- name: Checkout SpacetimeDB
74+
uses: actions/checkout@v4
75+
with:
76+
repository: clockworklabs/SpacetimeDB
77+
# ref: ${{ steps.extract-branch.outputs.branch }}
78+
path: SpacetimeDB
79+
80+
- name: Install Rust toolchain
81+
uses: dtolnay/rust-toolchain@stable
82+
83+
- name: Cache Rust dependencies
84+
uses: Swatinem/rust-cache@v2
85+
with:
86+
workspaces: SpacetimeDB/modules/quickstart-chat
87+
shared-key: quickstart-chat-test
88+
89+
- name: Install SpacetimeDB CLI from the local checkout
90+
run: |
91+
cargo install --force --path SpacetimeDB/crates/cli --locked --message-format=short
92+
cargo install --force --path SpacetimeDB/crates/standalone --locked --message-format=short
93+
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
94+
rm -f $HOME/.cargo/bin/spacetime
95+
ln -s $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime
96+
# Clear any existing information
97+
spacetime server clear -y
98+
env:
99+
# Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice.
100+
CARGO_TARGET_DIR: SpacetimeDB/modules/quickstart-chat/target
101+
102+
- name: Generate client bindings
103+
working-directory: SpacetimeDB/modules/quickstart-chat
104+
run: |
105+
spacetime generate --lang typescript --out-dir ../../../examples/quickstart-chat/src/module_bindings
106+
pnpm lint --write
107+
108+
- name: Check for changes
109+
run: |
110+
# This was copied from SpacetimeDB/tools/check-diff.sh.
111+
# It's required because `spacetime generate` creates lines with the SpacetimeDB commit
112+
# version, which would make this `git diff` check very brittle if included.
113+
PATTERN='^// This was generated using spacetimedb cli version.*'
114+
if ! git diff --exit-code --ignore-matching-lines="$PATTERN" -- examples/quickstart-chat/src/module_bindings; then
115+
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
116+
exit 1
117+
fi
118+
119+
# - name: Start SpacetimeDB
120+
# run: |
121+
# spacetime start &
122+
# disown
123+
124+
# - name: Publish module to SpacetimeDB
125+
# working-directory: SpacetimeDB/modules/quickstart-chat
126+
# run: |
127+
# spacetime logout && spacetime login --server-issued-login local
128+
# spacetime publish -s local quickstart-chat -c -y
129+
130+
# - name: Publish module to SpacetimeDB
131+
# working-directory: SpacetimeDB/modules/quickstart-chat
132+
# run: |
133+
# spacetime logs quickstart-chat
134+
135+
- name: Check that quickstart-chat builds
136+
working-directory: examples/quickstart-chat
137+
run: pnpm build
138+
139+
# - name: Run quickstart-chat tests
140+
# working-directory: examples/quickstart-chat
141+
# run: pnpm test
142+
#
143+
# # Run this step always, even if the previous steps fail
144+
# - name: Print rows in the user table
145+
# if: always()
146+
# run: spacetime sql quickstart-chat "SELECT * FROM user"

sdks/typescript/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
.envrc
3+
dist/
4+
.DS_Store

0 commit comments

Comments
 (0)