Skip to content

Commit 208ab8e

Browse files
authored
Merge pull request #354 from seamapi/evan/cx-410-do-not-generate-routes-or-endpoints-if-they-do-not-use-a
fix: Only generate endpoints with supported auth method
2 parents 7334a9e + f7c62d4 commit 208ab8e

File tree

26 files changed

+252
-2565
lines changed

26 files changed

+252
-2565
lines changed

codegen/lib/connect.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Blueprint } from '@seamapi/blueprint'
1+
import type { Blueprint, SeamAuthMethod } from '@seamapi/blueprint'
22
import { kebabCase } from 'change-case'
33
import type Metalsmith from 'metalsmith'
44

@@ -23,14 +23,34 @@ type File = RouteLayoutContext &
2323

2424
const rootPath = 'src/lib/seam/connect/routes'
2525

26+
const supportedAuthMethods: SeamAuthMethod[] = [
27+
'api_key',
28+
'publishable_key',
29+
'client_session_token',
30+
'personal_access_token',
31+
'console_session_token',
32+
]
33+
2634
export const connect = (
2735
files: Metalsmith.Files,
2836
metalsmith: Metalsmith,
2937
): void => {
3038
const metadata = metalsmith.metadata() as Metadata
31-
const {
32-
blueprint: { namespaces, routes },
33-
} = metadata
39+
const { blueprint } = metadata
40+
41+
const routes = blueprint.routes
42+
.filter((route) =>
43+
route.endpoints.some((endpoint) =>
44+
endpoint.authMethods.some((authMethod) =>
45+
supportedAuthMethods.includes(authMethod),
46+
),
47+
),
48+
)
49+
.filter((route) => !route.path.startsWith('/seam/mobile_sdk'))
50+
51+
const namespaces = blueprint.namespaces.filter((namespace) =>
52+
routes.some((route) => route.parentPath === namespace.path),
53+
)
3454

3555
const nodes = [...namespaces, ...routes]
3656

package-lock.json

Lines changed: 226 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
}
9494
},
9595
"dependencies": {
96-
"@seamapi/url-search-params-serializer": "^2.0.0-beta.2",
96+
"@seamapi/url-search-params-serializer": "^2.0.0",
9797
"axios": "^1.9.0",
9898
"axios-retry": "^4.4.2"
9999
},
100100
"devDependencies": {
101-
"@seamapi/blueprint": "^0.50.1",
101+
"@seamapi/blueprint": "^0.51.0",
102102
"@seamapi/fake-seam-connect": "^1.77.0",
103103
"@seamapi/smith": "^0.4.4",
104104
"@seamapi/types": "1.420.2",

src/lib/seam/connect/routes/seam-http-endpoints.ts

Lines changed: 0 additions & 252 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/seam/connect/routes/seam/bridge/index.ts

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

0 commit comments

Comments
 (0)