Skip to content

Commit 59530d0

Browse files
committed
openapi is not using stripe
1 parent ad1b45a commit 59530d0

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

apps/supabase/src/edge-functions/stripe-backfill-worker.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* to detect if all streams have completed.
88
*/
99

10-
import Stripe from 'npm:stripe'
1110
import pg from 'npm:pg@8'
1211
import { buildResourceRegistry } from '@stripe/source-stripe'
12+
import { resolveOpenApiSpec } from '@stripe/openapi'
1313
import { upsertMany } from '@stripe/destination-postgres'
1414

1515
// Module-level singletons (reused across requests in Deno edge functions)
@@ -22,9 +22,10 @@ const PAGES_PER_INVOCATION = Number(Deno.env.get('PAGES_PER_INVOCATION')) || 10
2222
const schemaName = Deno.env.get('SYNC_SCHEMA_NAME') ?? 'stripe'
2323
const safeSchema = schemaName.replace(/"/g, '""')
2424

25-
const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!)
25+
const stripeKey = Deno.env.get('STRIPE_SECRET_KEY')!
2626
const pool = new pg.Pool({ connectionString: dbUrl, max: 2 })
27-
const registry = buildResourceRegistry(stripe)
27+
const resolved = await resolveOpenApiSpec({ apiVersion: '2020-08-27' })
28+
const registry = buildResourceRegistry(resolved.spec, stripeKey)
2829

2930
/** Find the resource config whose tableName matches the given stream name. */
3031
function findConfigByTableName(stream: string) {
@@ -117,7 +118,7 @@ Deno.serve(async (req) => {
117118
let newRecords = 0
118119

119120
for (let page = 0; page < PAGES_PER_INVOCATION && hasMore; page++) {
120-
const params: Stripe.PaginationParams = { limit: 100 }
121+
const params: { limit: number; starting_after?: string } = { limit: 100 }
121122
if (cursor) params.starting_after = cursor
122123

123124
const response = await listFn(params)

apps/supabase/src/edge-functions/stripe-webhook.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import sourceStripe, {
44
} from '@stripe/source-stripe'
55
import destinationPostgres, { type Config as DestConfig } from '@stripe/destination-postgres'
66
import { catalogFromRegistry } from '@stripe/source-stripe'
7-
import Stripe from 'npm:stripe'
7+
import { resolveOpenApiSpec } from '@stripe/openapi'
88

99
Deno.serve(async (req) => {
1010
if (req.method !== 'POST') {
@@ -36,8 +36,8 @@ Deno.serve(async (req) => {
3636
batch_size: 100,
3737
}
3838

39-
const stripe = new Stripe(stripeKey)
40-
const registry = buildResourceRegistry(stripe)
39+
const resolved = await resolveOpenApiSpec({ apiVersion: '2020-08-27' })
40+
const registry = buildResourceRegistry(resolved.spec, stripeKey)
4141
const catalog = catalogFromRegistry(registry)
4242

4343
try {

apps/supabase/src/edge-functions/stripe-worker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* stripe-backfill-worker for parallel per-stream backfill.
88
*/
99

10-
import Stripe from 'npm:stripe'
1110
import pg from 'npm:pg@8'
1211
import { buildResourceRegistry, catalogFromRegistry } from '@stripe/source-stripe'
12+
import { resolveOpenApiSpec } from '@stripe/openapi'
1313

1414
// Module-level singletons (reused across requests in Deno edge functions)
1515
const dbUrl = Deno.env.get('SUPABASE_DB_URL')
@@ -21,9 +21,10 @@ const SYNC_INTERVAL = Number(Deno.env.get('SYNC_INTERVAL')) || 60 * 60 * 24 * 7
2121
const schemaName = Deno.env.get('SYNC_SCHEMA_NAME') ?? 'stripe'
2222
const safeSchema = schemaName.replace(/"/g, '""')
2323

24-
const stripe = new Stripe(Deno.env.get('STRIPE_SECRET_KEY')!)
24+
const stripeKey = Deno.env.get('STRIPE_SECRET_KEY')!
2525
const pool = new pg.Pool({ connectionString: dbUrl, max: 2 })
26-
const registry = buildResourceRegistry(stripe)
26+
const resolved = await resolveOpenApiSpec({ apiVersion: '2020-08-27' })
27+
const registry = buildResourceRegistry(resolved.spec, stripeKey)
2728

2829
Deno.serve(async (req) => {
2930
// Auth: validate Bearer token against vault worker secret

0 commit comments

Comments
 (0)