Skip to content

Commit a812ba2

Browse files
authored
Merge branch 'dev' into overview-revamp
2 parents 7ff0cf8 + 8aa80ce commit a812ba2

116 files changed

Lines changed: 5384 additions & 1666 deletions

File tree

Some content is hidden

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

.cursor/commands/pre-push.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Please compare `dev` to `main` and ensure that all migrations are backwards compatible. In what ways could breakage occur? Report the result to me in detail.
1+
Please compare `dev` to `main` and ensure that all migrations are backwards compatible. In what ways could breakage occur? Report the result to me in detail. Anything else that's scary that could occur, or that we should think about while migrating?

.github/workflows/db-migration-backwards-compatibility.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ jobs:
200200
uses: JarvusInnovations/background-action@v1.0.7
201201
if: ${{ hashFiles('apps/backend/scripts/run-cron-jobs.ts') != '' }}
202202
with:
203-
run: pnpm -C apps/backend run with-env:dev tsx scripts/run-cron-jobs.ts --log-order=stream &
203+
run: pnpm -C apps/backend run run-cron-jobs:test --log-order=stream &
204204
wait-on: |
205205
http://localhost:8102
206206
tail: true
@@ -394,7 +394,7 @@ jobs:
394394
uses: JarvusInnovations/background-action@v1.0.7
395395
if: ${{ hashFiles('apps/backend/scripts/run-cron-jobs.ts') != '' }}
396396
with:
397-
run: pnpm -C apps/backend run with-env:dev tsx scripts/run-cron-jobs.ts --log-order=stream &
397+
run: pnpm -C apps/backend run run-cron-jobs:test --log-order=stream &
398398
wait-on: |
399399
http://localhost:8102
400400
tail: true

.github/workflows/e2e-custom-base-port-api-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
- name: Start run-cron-jobs in background
146146
uses: JarvusInnovations/background-action@v1.0.7
147147
with:
148-
run: pnpm -C apps/backend run run-cron-jobs --log-order=stream &
148+
run: pnpm -C apps/backend run run-cron-jobs:test --log-order=stream &
149149
wait-on: |
150150
http://localhost:6702
151151
tail: true
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# TODO: keep in sync with e2e-tests.yaml — this is a near-copy with the backend
2+
# started on the fallback port (8110) only, so the SDK exercises fallback logic.
3+
name: Runs E2E Fallback Tests
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
- dev
10+
pull_request:
11+
12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
15+
16+
jobs:
17+
build:
18+
name: E2E Fallback Tests (Node ${{ matrix.node-version }})
19+
runs-on: ubicloud-standard-8
20+
env:
21+
NODE_ENV: test
22+
STACK_ENABLE_HARDCODED_PASSKEY_CHALLENGE_FOR_TESTING: yes
23+
STACK_DATABASE_CONNECTION_STRING: "postgres://postgres:PASSWORD-PLACEHOLDER--uqfEC1hmmv@localhost:8128/stackframe"
24+
STACK_EXTERNAL_DB_SYNC_MAX_DURATION_MS: "20000"
25+
STACK_EXTERNAL_DB_SYNC_DIRECT: "false"
26+
# SDK reads this as the primary URL, discovers hardcoded fallback to port 8110
27+
NEXT_PUBLIC_STACK_API_URL: "http://localhost:8102"
28+
# Tells js-helpers to omit explicit baseUrl so the SDK exercises fallback logic
29+
STACK_TEST_SDK_FALLBACK: "true"
30+
31+
strategy:
32+
matrix:
33+
node-version: [22.x]
34+
35+
steps:
36+
- uses: actions/checkout@v6
37+
38+
- name: Setup Node.js ${{ matrix.node-version }}
39+
uses: actions/setup-node@v6
40+
with:
41+
node-version: ${{ matrix.node-version }}
42+
43+
- name: Setup pnpm
44+
uses: pnpm/action-setup@v4
45+
46+
- name: Start Docker Compose in background
47+
uses: JarvusInnovations/background-action@v1.0.7
48+
with:
49+
run: docker compose -f docker/dependencies/docker.compose.yaml up --pull always -d &
50+
wait-on: /dev/null
51+
tail: true
52+
wait-for: 3s
53+
log-output-if: true
54+
55+
- name: Install dependencies
56+
run: pnpm install --frozen-lockfile
57+
58+
- name: Create .env.test.local files
59+
run: |
60+
cp apps/backend/.env.development apps/backend/.env.test.local
61+
cp apps/dashboard/.env.development apps/dashboard/.env.test.local
62+
cp apps/e2e/.env.development apps/e2e/.env.test.local
63+
cp docs/.env.development docs/.env.test.local
64+
cp examples/cjs-test/.env.development examples/cjs-test/.env.test.local
65+
cp examples/demo/.env.development examples/demo/.env.test.local
66+
cp examples/docs-examples/.env.development examples/docs-examples/.env.test.local
67+
cp examples/e-commerce/.env.development examples/e-commerce/.env.test.local
68+
cp examples/middleware/.env.development examples/middleware/.env.test.local
69+
cp examples/supabase/.env.development examples/supabase/.env.test.local
70+
cp examples/convex/.env.development examples/convex/.env.test.local
71+
72+
- name: Build
73+
run: pnpm build
74+
75+
- name: Wait on Postgres
76+
run: pnpm run wait-until-postgres-is-ready:pg_isready
77+
78+
- name: Wait on Inbucket
79+
run: pnpx wait-on tcp:localhost:8129
80+
81+
- name: Wait on Svix
82+
run: pnpx wait-on tcp:localhost:8113
83+
84+
- name: Wait on QStash
85+
run: pnpx wait-on tcp:localhost:8125
86+
87+
- name: Wait on ClickHouse
88+
run: pnpx wait-on http://localhost:8136/ping
89+
90+
- name: Initialize database
91+
run: pnpm run db:init
92+
93+
# Start backend ONLY on fallback port 8110 — primary port 8102 is intentionally left down
94+
# so the SDK exercises its fallback logic for every request.
95+
- name: Start stack-backend on fallback port (8110)
96+
uses: JarvusInnovations/background-action@v1.0.7
97+
with:
98+
run: pnpm -C apps/backend run with-env:test next start --port 8110 &
99+
wait-on: |
100+
http://localhost:8110
101+
tail: true
102+
wait-for: 30s
103+
log-output-if: true
104+
105+
- name: Start stack-dashboard in background
106+
uses: JarvusInnovations/background-action@v1.0.7
107+
with:
108+
run: pnpm run start:dashboard --log-order=stream &
109+
wait-on: |
110+
http://localhost:8101
111+
tail: true
112+
wait-for: 30s
113+
log-output-if: true
114+
115+
- name: Start mock-oauth-server in background
116+
uses: JarvusInnovations/background-action@v1.0.7
117+
with:
118+
run: pnpm run start:mock-oauth-server --log-order=stream &
119+
wait-on: |
120+
http://localhost:8110
121+
tail: true
122+
wait-for: 30s
123+
log-output-if: true
124+
125+
- name: Start run-email-queue in background
126+
uses: JarvusInnovations/background-action@v1.0.7
127+
with:
128+
run: pnpm -C apps/backend run run-email-queue --log-order=stream &
129+
wait-on: |
130+
http://localhost:8110
131+
tail: true
132+
wait-for: 30s
133+
log-output-if: true
134+
135+
- name: Start run-cron-jobs in background
136+
uses: JarvusInnovations/background-action@v1.0.7
137+
with:
138+
run: pnpm -C apps/backend run run-cron-jobs:test --log-order=stream &
139+
wait-on: |
140+
http://localhost:8110
141+
tail: true
142+
wait-for: 30s
143+
log-output-if: true
144+
145+
- name: Wait 10 seconds
146+
run: sleep 10
147+
148+
- name: Verify primary port 8102 is NOT running
149+
run: |
150+
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8102/health 2>/dev/null | grep -q "200"; then
151+
echo "ERROR: Primary backend on port 8102 should NOT be running for fallback tests"
152+
exit 1
153+
fi
154+
echo "Confirmed: primary port 8102 is down, fallback tests will exercise SDK fallback logic"
155+
156+
# Only run JS SDK tests — these exercise the SDK's fallback logic.
157+
# Backend API tests use direct HTTP calls that don't go through fallback.
158+
# Exclude cross-domain-auth which hardcodes the primary URL.
159+
- name: Run SDK fallback tests
160+
run: pnpm -w run pre && cd apps/e2e && npx vitest run tests/js/ --exclude '**/{cross-domain-auth,oauth,email-template-existing-project}*'
161+
162+
- name: Print Docker Compose logs
163+
if: always()
164+
run: docker compose -f docker/dependencies/docker.compose.yaml logs

.github/workflows/restart-dev-and-test-with-custom-base-port.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

.github/workflows/restart-dev-and-test.yaml

Lines changed: 0 additions & 46 deletions
This file was deleted.

apps/backend/.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,6 @@ STACK_STRIPE_SECRET_KEY=# enter your stripe api key
115115
STACK_STRIPE_WEBHOOK_SECRET=# enter your stripe webhook secret
116116
STACK_TELEGRAM_BOT_TOKEN= # enter you telegram bot token
117117
STACK_TELEGRAM_CHAT_ID=# enter your telegram chat id
118+
119+
# Docs AI tool bundle
120+
STACK_DOCS_INTERNAL_BASE_URL=# override the docs origin used by the backend's AI tool bundle to call the docs app's `/api/internal/docs-tools` endpoint. Defaults to http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}04 in dev, https://mcp.stack-auth.com in prod

apps/backend/.env.development

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ STACK_EMAIL_SENDER=noreply@example.com
5656

5757
STACK_ACCESS_TOKEN_EXPIRATION_TIME=60s
5858

59-
STACK_DEFAULT_EMAIL_CAPACITY_PER_HOUR=10000
59+
STACK_DEFAULT_EMAIL_CAPACITY_PER_HOUR=100000
6060

6161
STACK_SVIX_SERVER_URL=http://localhost:${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}13
6262
STACK_SVIX_API_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE2NTUxNDA2MzksImV4cCI6MTk3MDUwMDYzOSwibmJmIjoxNjU1MTQwNjM5LCJpc3MiOiJzdml4LXNlcnZlciIsInN1YiI6Im9yZ18yM3JiOFlkR3FNVDBxSXpwZ0d3ZFhmSGlyTXUifQ.En8w77ZJWbd0qrMlHHupHUB-4cx17RfzFykseg95SUk
@@ -77,6 +77,7 @@ STACK_OPENAI_API_KEY=mock_openai_api_key
7777
STACK_STRIPE_SECRET_KEY=sk_test_mockstripekey
7878
STACK_STRIPE_WEBHOOK_SECRET=mock_stripe_webhook_secret
7979
STACK_OPENROUTER_API_KEY=FORWARD_TO_PRODUCTION
80+
# STACK_DOCS_INTERNAL_BASE_URL=http://localhost:8104
8081
# Email monitor configuration for tests
8182
STACK_EMAIL_MONITOR_VERIFICATION_CALLBACK_URL=http://localhost:8101/handler/email-verification
8283
STACK_EMAIL_MONITOR_PROJECT_ID=internal

apps/backend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stackframe/backend",
3-
"version": "2.8.81",
3+
"version": "2.8.82",
44
"repository": "https://github.com/stack-auth/stack-auth",
55
"private": true,
66
"type": "module",
@@ -11,7 +11,7 @@
1111
"with-env:dev": "dotenv -c development --",
1212
"with-env:prod": "dotenv -c production --",
1313
"with-env:test": "dotenv -c test --",
14-
"dev": "concurrently -n \"dev,codegen,prisma-studio,email-queue,cron-jobs\" -k \"next dev --port ${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}02 ${STACK_BACKEND_DEV_EXTRA_ARGS:-}\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\" \"pnpm run run-email-queue\" \"pnpm run run-cron-jobs\"",
14+
"dev": "BACKEND_PORT=${STACK_DEV_FALLBACK_BACKEND:+${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}10} && BACKEND_PORT=${BACKEND_PORT:-${NEXT_PUBLIC_STACK_PORT_PREFIX:-81}02} && concurrently -n \"dev,codegen,prisma-studio,email-queue,cron-jobs\" -k \"next dev --port $BACKEND_PORT ${STACK_BACKEND_DEV_EXTRA_ARGS:-}\" \"pnpm run codegen:watch\" \"pnpm run prisma-studio\" \"pnpm run run-email-queue\" \"pnpm run run-cron-jobs\"",
1515
"dev:inspect": "STACK_BACKEND_DEV_EXTRA_ARGS=\"--inspect\" pnpm run dev",
1616
"dev:profile": "STACK_BACKEND_DEV_EXTRA_ARGS=\"--experimental-cpu-prof\" pnpm run dev",
1717
"build": "pnpm run codegen && next build",
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
-- CreateTable
2+
CREATE TABLE "AiConversation" (
3+
"id" UUID NOT NULL,
4+
"projectUserId" UUID NOT NULL,
5+
"projectId" TEXT NOT NULL REFERENCES "Project"("id") ON DELETE CASCADE ON UPDATE CASCADE,
6+
"title" TEXT NOT NULL,
7+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
8+
"updatedAt" TIMESTAMP(3) NOT NULL,
9+
10+
CONSTRAINT "AiConversation_pkey" PRIMARY KEY ("id")
11+
);
12+
13+
-- CreateTable
14+
CREATE TABLE "AiMessage" (
15+
"id" UUID NOT NULL,
16+
"conversationId" UUID NOT NULL REFERENCES "AiConversation"("id") ON DELETE CASCADE ON UPDATE CASCADE,
17+
"position" INTEGER NOT NULL,
18+
"role" TEXT NOT NULL,
19+
"content" JSONB NOT NULL,
20+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
21+
22+
CONSTRAINT "AiMessage_pkey" PRIMARY KEY ("id")
23+
);
24+
25+
-- CreateIndex
26+
CREATE INDEX "AiConversation_projectUserId_projectId_updatedAt_idx" ON "AiConversation"("projectUserId", "projectId", "updatedAt" DESC);
27+
28+
-- CreateIndex
29+
CREATE INDEX "AiMessage_conversationId_position_idx" ON "AiMessage"("conversationId", "position" ASC);

0 commit comments

Comments
 (0)