Skip to content

Commit ef33f60

Browse files
Merge branch 'supabase:main' into main
2 parents bf25b87 + b72ed02 commit ef33f60

Some content is hidden

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

54 files changed

+3765
-1676
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
services:
1616
postgres:
17-
image: postgres:17
17+
image: postgres:18
1818
ports:
1919
- 55432:5432
2020
env:
@@ -23,13 +23,13 @@ jobs:
2323
POSTGRES_PASSWORD: postgres
2424

2525
steps:
26-
- uses: actions/checkout@v5
26+
- uses: actions/checkout@v6
2727

2828
- name: Install pnpm
2929
uses: pnpm/action-setup@v4
3030

3131
- name: Set up Node
32-
uses: actions/setup-node@v4
32+
uses: actions/setup-node@v6
3333
with:
3434
node-version-file: ./.nvmrc
3535
cache: pnpm

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v5
12-
- uses: actions/setup-python@v5
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-python@v6
1313
with:
1414
python-version: 3.x
1515
- run: pip install mkdocs

.github/workflows/release.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ jobs:
1717
new-release-version: ${{ steps.semantic-release.outputs.new_release_version }}
1818

1919
steps:
20-
- uses: actions/checkout@v5
20+
- uses: actions/checkout@v6
2121

2222
- name: Install pnpm
2323
uses: pnpm/action-setup@v4
2424

2525
- name: Set up Node
26-
uses: actions/setup-node@v4
26+
uses: actions/setup-node@v6
2727
with:
2828
node-version-file: ./.nvmrc
2929
cache: pnpm
@@ -41,7 +41,8 @@ jobs:
4141

4242
docker:
4343
name: Release on Docker Hub
44-
44+
permissions:
45+
contents: read
4546
needs:
4647
- release
4748

@@ -77,7 +78,9 @@ jobs:
7778

7879
npm:
7980
name: Release on NPM
80-
81+
permissions:
82+
contents: read
83+
id-token: write # OIDC for releasing on npm
8184
needs:
8285
- release
8386

@@ -86,7 +89,7 @@ jobs:
8689
runs-on: ubuntu-24.04
8790

8891
steps:
89-
- uses: actions/checkout@v5
92+
- uses: actions/checkout@v6
9093
with:
9194
sparse-checkout: |
9295
packages/sync-engine
@@ -99,12 +102,15 @@ jobs:
99102
cd packages/sync-engine
100103
pnpm version ${{ needs.release.outputs.new-release-version }} --no-git-tag-version
101104
105+
- uses: actions/setup-node@v6
106+
with:
107+
node-version-file: .nvmrc
108+
cache: pnpm
109+
102110
- name: Publish sync-engine to npm
103111
run: |
104112
cd packages/sync-engine
105113
pnpm install --frozen-lockfile
106114
pnpm run build
107115
pnpm pack
108116
npm publish --access public
109-
env:
110-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v22
1+
v24

Dockerfile

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
# Build step
2-
FROM node:22-alpine
2+
FROM node:24-alpine AS base
33

4-
RUN npm install -g [email protected]
4+
ENV PNPM_HOME="/pnpm"
5+
ENV PATH="$PNPM_HOME:$PATH"
6+
7+
RUN corepack enable
58

69
WORKDIR /app
710
COPY . ./
8-
RUN pnpm install --frozen-lockfile
9-
RUN pnpm build
10-
RUN pnpm prune --production
11+
12+
FROM base AS prod-deps
13+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
14+
15+
FROM base AS build
16+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
17+
RUN pnpm run -r build
1118

1219
## Build step complete, copy to working image
13-
FROM node:22-alpine
20+
FROM node:24-alpine
1421
WORKDIR /app
22+
23+
# Copy workspace configuration
24+
COPY --from=base /app/package.json /app/pnpm-lock.yaml /app/pnpm-workspace.yaml* ./
25+
26+
# Copy package.json files for both packages
27+
COPY --from=base /app/packages/fastify-app/package.json /app/packages/fastify-app/
28+
COPY --from=base /app/packages/sync-engine/package.json /app/packages/sync-engine/
29+
30+
# Copy production dependencies (including workspace dependencies)
31+
COPY --from=prod-deps /app/node_modules /app/node_modules
32+
COPY --from=prod-deps /app/packages/fastify-app/node_modules /app/packages/fastify-app/node_modules
33+
COPY --from=prod-deps /app/packages/sync-engine/node_modules /app/packages/sync-engine/node_modules
34+
35+
# Copy built files
36+
COPY --from=build /app/packages/fastify-app/dist /app/packages/fastify-app/dist
37+
COPY --from=build /app/packages/sync-engine/dist /app/packages/sync-engine/dist
38+
1539
ENV NODE_ENV=production
16-
COPY --from=0 /app .
1740
CMD ["node", "packages/fastify-app/dist/src/server.js"]

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,37 @@
44
![NPM Version](https://img.shields.io/npm/v/%40supabase%2Fstripe-sync-engine)
55
![Docker Image Version](https://img.shields.io/docker/v/supabase/stripe-sync-engine?label=Docker)
66

7-
This monorepo contains two packages for synchronizing your Stripe account with a Postgres database:
7+
This monorepo contains two packages for synchronizing your Stripe account with a PostgreSQL database:
88

9-
- [`@supabase/stripe-sync-engine`](./packages/sync-engine/README.md): A TypeScript library for syncing Stripe data to Postgres, designed for integration into your own Node.js backend or serverless environment.
10-
- [`stripe-sync-fastify`](./packages/fastify-app/README.md): A Fastify-based server and Docker image that exposes a `/webhooks` endpoint for Stripe, providing a ready-to-run service for real-time Stripe-to-Postgres sync.
9+
- [`@supabase/stripe-sync-engine`](./packages/sync-engine/README.md): A TypeScript library for syncing Stripe data to PostgreSQL, designed for integration into your own Node.js backend or serverless environment.
10+
- [`stripe-sync-fastify`](./packages/fastify-app/README.md): A Fastify-based server and Docker image that exposes a `/webhooks` endpoint for Stripe, providing a ready-to-run service for real-time Stripe-to-PostgreSQL sync.
1111

12-
![Sync Stripe with Postgres](./docs/stripe-sync-engine.jpg)
12+
![Sync Stripe with PostgreSQL](./docs/stripe-sync-engine.jpg)
1313

1414
---
1515

1616
## Motivation
1717

1818
Sometimes you want to analyze your billing data using SQL. Even more importantly, you want to join your billing data to your product/business data.
1919

20-
This project synchronizes your Stripe account to a Postgres database. It can be a new database, or an existing Postgres database.
20+
This project synchronizes your Stripe account to a PostgreSQL database. It can be a new database, or an existing PostgreSQL database.
2121

2222
---
2323

2424
## How it works
2525

2626
![How it works](./docs/sync-engine-how.png)
2727

28-
- Creates a new schema `stripe` in a Postgres database, with tables & columns matching Stripe.
28+
- Creates a new schema `stripe` in a PostgreSQL database, with tables and columns matching Stripe.
2929
- Exposes a `/webhooks` endpoint that listens to any Stripe webhooks (via the Fastify app).
30-
- Inserts/updates/deletes changes into the tables whenever there is a change to Stripe.
30+
- Inserts, updates, or deletes changes into the tables whenever there is a change to Stripe.
31+
32+
> **Note:** If other PostgreSQL users need access to the `stripe` schema, grant them privileges:
33+
>
34+
> ```sql
35+
> GRANT USAGE ON SCHEMA stripe TO your_user;
36+
> GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA stripe TO your_user;
37+
> ```
3138
3239
---
3340
@@ -42,7 +49,7 @@ Each package has its own README with installation, configuration, and usage inst
4249
4350
## Supabase Edge Function
4451
45-
To deploy the sync-engine to a Supabase edge function, follow this [guide](./edge-function.md).
52+
To deploy the sync-engine to a Supabase Edge Function, follow this [guide](./docs/edge-function.md).
4653
4754
## Webhook Support
4855
@@ -60,9 +67,10 @@ To deploy the sync-engine to a Supabase edge function, follow this [guide](./edg
6067
- [x] `charge.dispute.funds_reinstated` 🟢
6168
- [x] `charge.dispute.funds_withdrawn` 🟢
6269
- [x] `charge.dispute.updated` 🟢
63-
- [ ] `checkout.session.async_payment_failed`
64-
- [ ] `checkout.session.async_payment_succeeded`
65-
- [ ] `checkout.session.completed`
70+
- [x] `checkout.session.async_payment_failed` 🟢
71+
- [x] `checkout.session.async_payment_succeeded` 🟢
72+
- [x] `checkout.session.completed` 🟢
73+
- [x] `checkout.session.expired` 🟢
6674
- [x] `credit_note.created` 🟢
6775
- [x] `credit_note.updated` 🟢
6876
- [x] `credit_note.voided` 🟢
@@ -98,6 +106,7 @@ To deploy the sync-engine to a Supabase edge function, follow this [guide](./edg
98106
- [x] `invoice.overpaid` 🟢
99107
- [x] `invoice.will_be_due` 🟢
100108
- [x] `invoice.voided` 🟢
109+
- [x] `invoice_payment.paid` 🟢
101110
- [ ] `issuing_authorization.request`
102111
- [ ] `issuing_card.created`
103112
- [ ] `issuing_cardholder.created`
@@ -141,3 +150,4 @@ To deploy the sync-engine to a Supabase edge function, follow this [guide](./edg
141150
- [x] `subscription_schedule.expiring` 🟢
142151
- [x] `subscription_schedule.released` 🟢
143152
- [x] `subscription_schedule.updated` 🟢
153+
- [x] `entitlements.active_entitlement_summary.updated` 🟢

docs/contributing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing
22

3-
Contributions are welcome.
3+
Contributions are welcome! This document provides guidelines for contributing to the Stripe Sync Engine project.
44

55
## Contributing to the Docs
66

@@ -10,7 +10,7 @@ Building documentation requires Python 3.8+ and uv.
1010

1111
Create a virtual environment and install mkdocs, themes, and extensions using uv.
1212

13-
```shell
13+
```sh
1414
source .venv/bin/activate # On Windows: .venv\Scripts\activate
1515
uv pip install -r docs/requirements_docs.txt
1616
```
@@ -19,7 +19,7 @@ uv pip install -r docs/requirements_docs.txt
1919

2020
To serve the documentation locally, make sure your virtual environment is activated and run:
2121

22-
```shell
22+
```sh
2323
source .venv/bin/activate # On Windows: .venv\Scripts\activate
2424
mkdocs serve
2525
```
@@ -28,8 +28,8 @@ and visit the docs at [http://127.0.0.1:8000/](http://127.0.0.1:8000/)
2828

2929
### Deploying
3030

31-
If you have write access to the repo, docs can be updated using
31+
If you have write access to the repository, documentation can be updated using:
3232

33-
```
33+
```sh
3434
mkdocs gh-deploy
3535
```

0 commit comments

Comments
 (0)