diff --git a/.gitignore b/.gitignore index eb81fc6..f395f7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .prism.log +.stdy.log .venv temp/ regress/ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 10f3091..b06ba91 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.2.0" + ".": "0.2.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a39898..4b12aa9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## 0.2.1 (2026-04-18) + +Full Changelog: [v0.2.0...v0.2.1](https://github.com/stainless-commons/stripe-sql/compare/v0.2.0...v0.2.1) + +### Chores + +* **internal:** support env vars in `./scripts/repl` ([e61819d](https://github.com/stainless-commons/stripe-sql/commit/e61819df63d91bf0f6b10ecc2abf8730b390d401)) +* **internal:** update gitignore ([69bef31](https://github.com/stainless-commons/stripe-sql/commit/69bef3126b1bd07a04bc674559262920b03c29ec)) +* **internal:** update multipart form array serialization ([f710526](https://github.com/stainless-commons/stripe-sql/commit/f7105265acdf5b566798f3fcf58528f1bb95b192)) +* **tests:** bump steady to v0.19.4 ([0037da0](https://github.com/stainless-commons/stripe-sql/commit/0037da0bb51eace12f3df31216ee2cab695b7b9a)) +* **tests:** bump steady to v0.19.5 ([34e63fb](https://github.com/stainless-commons/stripe-sql/commit/34e63fb004f010e4fed95b3f8b357c4236d0d9e0)) +* **tests:** bump steady to v0.19.6 ([01d5cde](https://github.com/stainless-commons/stripe-sql/commit/01d5cdebb2577d2bd3716a53aae26654a6881e65)) +* **tests:** bump steady to v0.19.7 ([77881f1](https://github.com/stainless-commons/stripe-sql/commit/77881f17bf5ec4d3aae93842e35522b1626b3153)) +* **tests:** bump steady to v0.20.1 ([caecce0](https://github.com/stainless-commons/stripe-sql/commit/caecce006ec4da82fe07d4007e7033ed5d7f0b34)) +* **tests:** bump steady to v0.20.2 ([65b284f](https://github.com/stainless-commons/stripe-sql/commit/65b284f35ffae8cb04abdee3ee2a0161882923cc)) +* **tests:** bump steady to v0.22.1 ([ef16d9b](https://github.com/stainless-commons/stripe-sql/commit/ef16d9b6411f06e7f424938ceaab2174a3077ae9)) + + +### Documentation + +* explain caching ([c9ad730](https://github.com/stainless-commons/stripe-sql/commit/c9ad7300a4a279955f8fc2ef1f4cf8b7a3d45c39)) + ## 0.2.0 (2026-03-17) Full Changelog: [v0.1.1...v0.2.0](https://github.com/stainless-commons/stripe-sql/compare/v0.1.1...v0.2.0) diff --git a/README.md b/README.md index 19a431b..7f61324 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,23 @@ 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 Stripe 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 stripe_coupons AS +SELECT * +FROM stripe_coupons.list(); + +-- Refresh the view every 4 hours. +SELECT cron.schedule( + 'refresh-stripe-coupons', + '0 */4 * * *', + 'REFRESH MATERIALIZED VIEW CONCURRENTLY stripe_coupons' +); +``` + ## Troubleshooting ### Installation diff --git a/scripts/mock b/scripts/mock index 3d1d19c..04d2901 100755 --- a/scripts/mock +++ b/scripts/mock @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}" # 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=@stdy/cli@0.19.3 -- steady --version + npm exec --package=@stdy/cli@0.22.1 -- steady --version - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" &> .stdy.log & + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stdy/cli@0.19.3 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets "$URL" + npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/repl b/scripts/repl index 21d1eab..e3230ef 100755 --- a/scripts/repl +++ b/scripts/repl @@ -29,8 +29,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 @@ -61,10 +61,17 @@ done echo "==> Running setup.sql" psql -d postgres -f test/sql/create_extension.sql +if [ -n "$STRIPE_SECRET_KEY" ]; then + psql -d postgres --variable "value='$STRIPE_SECRET_KEY'" -c 'ALTER DATABASE postgres SET stripe.secret_key = :value;' +fi +if [ -n "$STRIPE_BASE_URL" ]; then + psql -d postgres --variable "value='$STRIPE_BASE_URL'" -c 'ALTER DATABASE postgres SET stripe.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 \ No newline at end of file diff --git a/scripts/test b/scripts/test index 1431f54..a53a58f 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! steady_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.19.3 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-query-object-format=brackets${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1