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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.prism.log
.stdy.log
.venv
temp/
regress/
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.2.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 23
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-5a8ac7b545c48dc892e5c680303e305254921554dabee848e40a808659dbcf1e.yml
openapi_spec_hash: 0103975601aac1445d3a4ef418c5d17a
config_hash: ca148af6be59ec54295b2c5f852a38d1
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/beeper%2Fbeeper-desktop-api-611aa7641fbca8cf31d626bf86f9efd3c2b92778e897ebbb25c6ea44185ed1ed.yml
openapi_spec_hash: d6c0a1776048dab04f6c5625c9893c9c
config_hash: 39ed0717b5f415499aaace2468346e1a
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Changelog

## 0.2.0 (2026-04-12)

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

### Features

* **api:** add network, bridge fields to accounts ([41e2829](https://github.com/beeper/desktop-api-sql/commit/41e28294a7fcad3839ea2d3c5c3b48061774776f))


### 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))
* **internal:** update gitignore ([998e1de](https://github.com/beeper/desktop-api-sql/commit/998e1de2a033f9cb44326e681eadc5cbd25d862b))
* **internal:** update multipart form array serialization ([0af81d8](https://github.com/beeper/desktop-api-sql/commit/0af81d8b40c42ae06bac4d2ee9d9bcf5fb887641))
* **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))
* **tests:** bump steady to v0.19.6 ([827b6a2](https://github.com/beeper/desktop-api-sql/commit/827b6a2c9d2f7db42f469a86f207318e1441a46a))
* **tests:** bump steady to v0.19.7 ([be70621](https://github.com/beeper/desktop-api-sql/commit/be70621335ade7130eedb59982ff75f36c3ce75a))
* **tests:** bump steady to v0.20.1 ([1c13343](https://github.com/beeper/desktop-api-sql/commit/1c1334345f7df0ab235018431f6f64026db45332))
* **tests:** bump steady to v0.20.2 ([60ca024](https://github.com/beeper/desktop-api-sql/commit/60ca0242076c462be6e9da54a39b1138a56b9732))
* update SDK settings ([71dc986](https://github.com/beeper/desktop-api-sql/commit/71dc9866112525943eb11a430cf2505236cc3f46))


### 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
1 change: 0 additions & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"version": "0.0.1",
"release_status": "testing",
"maintainer": "Beeper Desktop <help@beeper.com>",
"generated_by": "Stainless (https://stainless.com)",
"license": "mit",
"resources": {
"homepage": "https://developers.beeper.com/desktop-api/",
Expand Down
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

The Beeper Desktop API PostgreSQL Extension provides convenient access to the [Beeper Desktop REST API](https://developers.beeper.com/desktop-api/) from PostgreSQL.

It is generated with [Stainless](https://www.stainless.com/).

The REST API documentation can be found on [developers.beeper.com](https://developers.beeper.com/desktop-api/).

## Installation
Expand Down Expand Up @@ -89,15 +87,11 @@ See this table for the available configuration parameters:

To send a request to the Beeper Desktop API, call the relevant SQL function with values corresponding to the parameter types and `SELECT` the columns you need from the returned rows.

To construct [composite type](https://www.postgresql.org/docs/current/rowtypes.html) parameters, use the parameter type's provided `make_*` function. For example, `beeper_desktop_api_chats.create_params_user` may be constructed like so:
To construct [composite type](https://www.postgresql.org/docs/current/rowtypes.html) parameters, use the parameter type's provided `make_*` function. For example, `beeper_desktop_api_chats_reminders.create_params_reminder` may be constructed like so:

```sql
beeper_desktop_api_chats.make_create_params_user(
id := 'id',
email := 'email',
fullName := 'fullName',
phoneNumber := 'phoneNumber',
username := 'username'
beeper_desktop_api_chats_reminders.make_create_params_reminder(
remindAtMs := 0, dismissOnIncomingMessage := TRUE
)
```

Expand All @@ -123,6 +117,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.20.2 -- steady --version

npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log &
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-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.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-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.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=repeat --validator-form-array-format=repeat --validator-query-object-format=brackets --validator-form-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
4 changes: 3 additions & 1 deletion sql/_beeper_desktop_api.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ CREATE TYPE beeper_desktop_api.client_search_response_result_message AS ();
CREATE SCHEMA IF NOT EXISTS beeper_desktop_api_accounts;

CREATE TYPE beeper_desktop_api_accounts.account AS ();
CREATE TYPE beeper_desktop_api_accounts.account_bridge AS ();

CREATE SCHEMA IF NOT EXISTS beeper_desktop_api_accounts_contacts;

Expand All @@ -134,7 +135,8 @@ CREATE TYPE beeper_desktop_api_chats.chat_participant AS ();
CREATE TYPE beeper_desktop_api_chats.chat_create_response AS ();
CREATE TYPE beeper_desktop_api_chats.chat_list_response AS ();
CREATE TYPE beeper_desktop_api_chats.chat_list_response_participant AS ();
CREATE TYPE beeper_desktop_api_chats.create_params_user AS ();
CREATE TYPE beeper_desktop_api_chats.create_params_param AS ();
CREATE TYPE beeper_desktop_api_chats.create_params_param_create_params_user AS ();

CREATE SCHEMA IF NOT EXISTS beeper_desktop_api_chats_reminders;

Expand Down
27 changes: 24 additions & 3 deletions sql/beeper_desktop_api_accounts.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,35 @@
ALTER TYPE beeper_desktop_api_accounts.account
ADD ATTRIBUTE accountID TEXT, ADD ATTRIBUTE "user" beeper_desktop_api.user;
ADD ATTRIBUTE accountID TEXT,
ADD ATTRIBUTE bridge beeper_desktop_api_accounts.account_bridge,
ADD ATTRIBUTE network TEXT,
ADD ATTRIBUTE "user" beeper_desktop_api.user;

CREATE OR REPLACE FUNCTION beeper_desktop_api_accounts.make_account(
accountID TEXT, "user" beeper_desktop_api.user
accountID TEXT,
bridge beeper_desktop_api_accounts.account_bridge,
network TEXT,
"user" beeper_desktop_api.user
)
RETURNS beeper_desktop_api_accounts.account
LANGUAGE SQL
IMMUTABLE
AS $$
SELECT ROW(accountID, "user")::beeper_desktop_api_accounts.account;
SELECT ROW(
accountID, bridge, network, "user"
)::beeper_desktop_api_accounts.account;
$$;

ALTER TYPE beeper_desktop_api_accounts.account_bridge
ADD ATTRIBUTE id TEXT, ADD ATTRIBUTE provider TEXT, ADD ATTRIBUTE type TEXT;

CREATE OR REPLACE FUNCTION beeper_desktop_api_accounts.make_account_bridge(
id TEXT, provider TEXT, type TEXT
)
RETURNS beeper_desktop_api_accounts.account_bridge
LANGUAGE SQL
IMMUTABLE
AS $$
SELECT ROW(id, provider, type)::beeper_desktop_api_accounts.account_bridge;
$$;

CREATE OR REPLACE FUNCTION beeper_desktop_api_accounts._list()
Expand Down
Loading
Loading