Skip to content

Commit ad1b45a

Browse files
committed
openapi doesn't use sdk
1 parent aaa21fa commit ad1b45a

3 files changed

Lines changed: 9 additions & 21 deletions

File tree

packages/source-stripe/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const source = {
117117
const resolved = await resolveOpenApiSpec({
118118
apiVersion: config.api_version ?? '2020-08-27',
119119
})
120-
const registry = buildResourceRegistry(makeClient(config), resolved.spec, config.api_key)
120+
const registry = buildResourceRegistry(resolved.spec, config.api_key)
121121
try {
122122
const parser = new SpecParser()
123123
const parsed = parser.parse(resolved.spec, {
@@ -173,7 +173,7 @@ const source = {
173173
const resolved = await resolveOpenApiSpec({
174174
apiVersion: config.api_version ?? '2020-08-27',
175175
})
176-
const registry = buildResourceRegistry(stripe, resolved.spec, config.api_key)
176+
const registry = buildResourceRegistry(resolved.spec, config.api_key)
177177
const streamNames = new Set(catalog.streams.map((s) => s.stream.name))
178178

179179
// Event-driven mode: iterate over incoming webhook inputs

packages/source-stripe/src/resourceRegistry.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import Stripe from 'stripe'
21
import type { ResourceConfig } from './types'
32
import type { OpenApiSpec, NestedEndpoint } from '@stripe/openapi'
43
import {
54
discoverListEndpoints,
65
discoverNestedEndpoints,
6+
isV2Path,
77
buildListFn,
88
buildRetrieveFn,
9-
canResolveSdkResource,
10-
isV2Path,
119
RUNTIME_REQUIRED_TABLES as OPENAPI_RUNTIME_REQUIRED_TABLES,
1210
} from '@stripe/openapi'
1311

@@ -65,7 +63,6 @@ export const RESOURCE_TABLE_NAME_MAP: Record<string, string> = Object.fromEntrie
6563
* All resources get list + retrieve functions derived dynamically from the spec paths.
6664
*/
6765
export function buildResourceRegistry(
68-
stripe: Stripe,
6966
spec: OpenApiSpec,
7067
apiKey: string
7168
): Record<string, ResourceConfig> {
@@ -76,7 +73,6 @@ export function buildResourceRegistry(
7673

7774
for (const [tableName, endpoint] of endpoints) {
7875
const v2 = isV2Path(endpoint.apiPath)
79-
if (!v2 && !canResolveSdkResource(stripe, endpoint.apiPath)) continue
8076

8177
const children = nestedEndpoints
8278
.filter((n: NestedEndpoint) => n.parentTableName === tableName)
@@ -95,8 +91,8 @@ export function buildResourceRegistry(
9591
supportsLimit: endpoint.supportsLimit,
9692
sync: true,
9793
dependencies: [],
98-
listFn: buildListFn(stripe, endpoint.apiPath, apiKey),
99-
retrieveFn: buildRetrieveFn(stripe, endpoint.apiPath, apiKey),
94+
listFn: buildListFn(apiKey, endpoint.apiPath),
95+
retrieveFn: buildRetrieveFn(apiKey, endpoint.apiPath),
10096
nestedResources: children.length > 0 ? children : undefined,
10197
}
10298
registry[tableName] = config

packages/source-stripe/src/types.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Stripe from 'stripe'
1+
import type Stripe from 'stripe'
2+
import type { ListFn, RetrieveFn } from '@stripe/openapi'
23
import type { RevalidateEntityName } from './resourceRegistry'
34

45
/**
@@ -30,19 +31,10 @@ export type BaseResourceConfig = {
3031
}
3132

3233
export type ResourceConfig = BaseResourceConfig & {
33-
/** Function to list items from Stripe API */
34-
listFn?: (params: Stripe.PaginationParams & { created?: Stripe.RangeQueryParam }) => Promise<{
35-
data: unknown[]
36-
has_more: boolean
37-
pageCursor?: string
38-
}>
39-
/** Function to retrieve a single item by ID from Stripe API */
40-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41-
retrieveFn?: (id: string) => Promise<Stripe.Response<any>>
34+
listFn?: ListFn
35+
retrieveFn?: RetrieveFn
4236
/** Whether the list API supports the `limit` parameter */
4337
supportsLimit?: boolean
44-
/** Optional list of sub-resources to expand during upsert/fetching (e.g. 'refunds', 'listLineItems') */
45-
listExpands?: Record<string, (id: string) => Promise<Stripe.ApiList<{ id?: string }>>>[]
4638
/** Nested child resources discovered from the spec (e.g. subscription items under subscriptions) */
4739
nestedResources?: {
4840
tableName: string

0 commit comments

Comments
 (0)