Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: CI
on:
push:
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
branches:
- '**'
- '!integrated/**'
- '!stl-preview-head/**'
- '!stl-preview-base/**'
- '!generated'
- '!codegen/**'
- 'codegen/stl/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.1.1"
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 0.1.1 (2026-03-21)

Full Changelog: [v0.1.0...v0.1.1](https://github.com/beeper/desktop-api-sql/compare/v0.1.0...v0.1.1)

### Chores

* **internal:** codegen related update ([91994fa](https://github.com/beeper/desktop-api-sql/commit/91994fa8b9e406c674d5245f2da123608e87046b))
* **internal:** support env vars in `./scripts/repl` ([9183ad1](https://github.com/beeper/desktop-api-sql/commit/9183ad1d77206204a8650471616d1f97b817f024))
* **internal:** tweak CI branches ([2db5518](https://github.com/beeper/desktop-api-sql/commit/2db5518d6ac525ccd1d753e271f6adcde42398bf))
* **tests:** bump steady to v0.19.4 ([fe76f5e](https://github.com/beeper/desktop-api-sql/commit/fe76f5e4d60950521215581557cd0453720d7a71))
* **tests:** bump steady to v0.19.5 ([71cbd2c](https://github.com/beeper/desktop-api-sql/commit/71cbd2c8566c6c466557c8ee7209f6710687cf1a))


### Documentation

* explain caching ([d84f8a5](https://github.com/beeper/desktop-api-sql/commit/d84f8a50545721a86b7ea48a8af34bd588961c54))


### Refactors

* **tests:** switch from prism to steady ([ca3c264](https://github.com/beeper/desktop-api-sql/commit/ca3c264cee5d12947269f7fc6f919eb8db071c9b))

## 0.1.0 (2026-03-13)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/beeper/desktop-api-sql/compare/v0.0.1...v0.1.0)
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,27 @@ LIMIT 200;
> removed, then PostgreSQL may not [push down the condition](https://wiki.postgresql.org/wiki/Inlining_of_SQL_functions),
> causing all pages to be requested and buffered.

## Caching

Sending requests to the Beeper Desktop API for every SQL query can be slow. Combine [materialized views](https://www.postgresql.org/docs/current/rules-materializedviews.html) with [`pg_cron`](https://github.com/citusdata/pg_cron) for scheduled data pulls:

```sql
CREATE MATERIALIZED VIEW beeper_desktop_api_messages AS
SELECT *
FROM beeper_desktop_api_messages.search(
account_ids := ARRAY['local-telegram_ba_QFrb5lrLPhO3OT5MFBeTWv0x4BI'],
"limit" := 10,
query := 'deployment'
);

-- Refresh the view every 4 hours.
SELECT cron.schedule(
'refresh-beeper-desktop-api-messages',
'0 */4 * * *',
'REFRESH MATERIALIZED VIEW CONCURRENTLY beeper_desktop_api_messages'
);
```

## Troubleshooting

### Installation
Expand Down
26 changes: 13 additions & 13 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,34 @@ fi

echo "==> Starting mock server with URL ${URL}"

# Run prism mock on the given spec
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism --version
npm exec --package=@stdy/cli@0.19.5 -- steady --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online (max 30s)
# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
attempts=0
while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do
while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do
if ! kill -0 $! 2>/dev/null; then
echo
cat .stdy.log
exit 1
fi
attempts=$((attempts + 1))
if [ "$attempts" -ge 300 ]; then
echo
echo "Timed out waiting for Prism server to start"
cat .prism.log
echo "Timed out waiting for Steady server to start"
cat .stdy.log
exit 1
fi
echo -n "."
sleep 0.1
done

if grep -q "✖ fatal" ".prism.log"; then
cat .prism.log
exit 1
fi

echo
else
npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL"
npm exec --package=@stdy/cli@0.19.5 -- steady --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets "$URL"
fi
16 changes: 13 additions & 3 deletions scripts/repl
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/usr/bin/env bash

if [ -z "$BEEPER_ACCESS_TOKEN" ]; then
echo 'ERROR: BEEPER_ACCESS_TOKEN environment variable is required but not set'
exit 1
fi

echo "==> Detecting PostgreSQL Python executable"
PYTHON_EXECUTABLE_PATH=$(pg_config --configure | grep -o "PYTHON=[^ ]*" | cut -d= -f2 | tr -d "'")
echo "PostgreSQL uses Python $PYTHON_EXECUTABLE_PATH"
Expand Down Expand Up @@ -29,8 +34,8 @@ if [ "$PG_MAJOR_VERSION" -ge 18 ]; then
done
POSTGRES_CONFIG=(-c extension_control_path="$(realpath temp/install/share/postgresql)")
else
# In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install directly to
# the system.
# In PostgreSQL <18 we cannot point `postgres` to our local extensions directory. So we install
# directly to the system.
sudo make install PG_CONFIG="$(command -v pg_config)"
fi

Expand Down Expand Up @@ -61,10 +66,15 @@ done
echo "==> Running setup.sql"
psql -d postgres -f test/sql/create_extension.sql

psql -d postgres --variable "value='$BEEPER_ACCESS_TOKEN'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.beeper_access_token = :value;'
if [ -n "$BEEPER_DESKTOP_BASE_URL" ]; then
psql -d postgres --variable "value='$BEEPER_DESKTOP_BASE_URL'" -c 'ALTER DATABASE postgres SET beeper_desktop_api.base_url = :value;'
fi

if command -v pgcli &>/dev/null; then
echo "==> Starting pgcli REPL"
pgcli postgres
else
echo "==> Starting psql REPL (TIP: Install pgcli for better autocomplete!)"
psql -d postgres
fi
fi
16 changes: 8 additions & 8 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color

function prism_is_running() {
curl --silent "http://localhost:4010" >/dev/null 2>&1
function steady_is_running() {
curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1
}

kill_server_on_port() {
Expand All @@ -25,7 +25,7 @@ function is_overriding_api_base_url() {
[ -n "$TEST_API_BASE_URL" ]
}

if ! is_overriding_api_base_url && ! prism_is_running ; then
if ! is_overriding_api_base_url && ! steady_is_running ; then
# When we exit this script, make sure to kill the background mock server process
trap 'kill_server_on_port 4010' EXIT

Expand All @@ -36,19 +36,19 @@ fi
if is_overriding_api_base_url ; then
echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}"
echo
elif ! prism_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server"
elif ! steady_is_running ; then
echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server"
echo -e "running against your OpenAPI spec."
echo
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the prism command:"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.5 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-form-array-format=repeat --validator-query-array-format=repeat --validator-form-object-format=brackets --validator-query-object-format=brackets${NC}"
echo

exit 1
else
echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}"
echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}"
echo
fi

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading