Skip to content

Commit 25c58dd

Browse files
authored
fix: Export SeamHttpEndpointQueryPaths and SeamHttpEndpointMutationPaths (#351)
1 parent 5d7b1a2 commit 25c58dd

File tree

3 files changed

+109
-93
lines changed

3 files changed

+109
-93
lines changed

codegen/layouts/endpoints.hbs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ export class SeamHttpEndpoints {
3636
{{/each}}
3737
}
3838

39-
export type SeamHttpEndpointPaths = {{#each endpoints}}'{{path}}' {{#unless @last}} | {{/unless}}{{/each}}
39+
export type SeamHttpEndpointMutationPaths = {{#each endpointReadPaths}}'{{.}}' {{#unless @last}} | {{/unless}}{{/each}}
40+
41+
export type SeamHttpEndpointQueryPaths = {{#each endpointWritePaths}}'{{.}}' {{#unless @last}} | {{/unless}}{{/each}}

codegen/lib/layouts/endpoints.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
export interface EndpointsLayoutContext {
1111
className: string
1212
endpoints: EndpointLayoutContext[]
13+
endpointReadPaths: string[]
14+
endpointWritePaths: string[]
1315
routeImports: RouteImportLayoutContext[]
1416
skipClientSessionImport: boolean
1517
}
@@ -31,6 +33,16 @@ export const setEndpointsLayoutContext = (
3133
getEndpointLayoutContext(endpoint, route),
3234
),
3335
)
36+
file.endpointReadPaths = routes.flatMap((route) =>
37+
route.endpoints
38+
.filter(({ request }) => request.semanticMethod === 'GET')
39+
.map(({ path }) => path),
40+
)
41+
file.endpointWritePaths = routes.flatMap((route) =>
42+
route.endpoints
43+
.filter(({ request }) => request.semanticMethod !== 'GET')
44+
.map(({ path }) => path),
45+
)
3446
file.routeImports = routes.map((route) => {
3547
const endpoints = route.endpoints.map((endpoint) =>
3648
getEndpointLayoutContext(endpoint, route),

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

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

0 commit comments

Comments
 (0)