Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/prune.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Prune

on:
workflow_dispatch: {}
schedule:
- cron: '0 15 * * 3'

jobs:
tag:
name: Prune Branches
runs-on: 'ubuntu-latest'
timeout-minutes: 30
permissions:
pull-requests: read
contents: write
steps:
- name: Prune stale branches
uses: balvajs/delete-stale-branches@v2
with:
dry-run: false
days-to-delete: 7
4 changes: 2 additions & 2 deletions ava.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default () => {

return {
files: ['**/*.test.ts', '!package/**/*'],
ignoreChanges: {
watchMode: ['tmp/**/*'],
watchMode: {
ignoreChanges: ['tmp/**/*'],
},
extensions: ['ts'],
nodeArguments: ['--import=tsx'],
Expand Down
6 changes: 6 additions & 0 deletions codegen/layouts/partials/route-class-endpoint.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
{{requestFormat}}: parameters,
responseKey: {{#if returnsVoid}}undefined{{else}}'{{responseKey}}'{{/if}},
options,
{{#if returnsActionAttempt}}
actionAttempts: SeamHttpActionAttempts.fromClient(this.client, {
...this.defaults,
waitForActionAttempt: false,
}),
{{/if}}
})
}
3 changes: 3 additions & 0 deletions codegen/layouts/partials/route-imports.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ import {
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'

{{#if needsActionAttemptsImport}}
import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js'
{{/if}}
{{#unless skipClientSessionImport}}
import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
{{/unless}}
Expand Down
14 changes: 11 additions & 3 deletions codegen/lib/layouts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface RouteLayoutContext {
endpoints: EndpointLayoutContext[]
subroutes: SubrouteLayoutContext[]
skipClientSessionImport: boolean
needsActionAttemptsImport: boolean
resourceTypeImports: ResourceTypeImport[]
}

Expand Down Expand Up @@ -58,6 +59,11 @@ export const setRouteLayoutContext = (
file.className = getClassName(node?.path ?? null)
file.skipClientSessionImport =
node == null || node?.path === '/client_sessions'
file.needsActionAttemptsImport =
node != null &&
node.path !== '/action_attempts' &&
'endpoints' in node &&
node.endpoints.some(isActionAttemptEndpoint)
file.resourceTypeImports =
node != null && 'endpoints' in node
? [
Expand Down Expand Up @@ -115,9 +121,7 @@ export const getEndpointLayoutContext = (
? 'params'
: 'body'

const returnsActionAttempt =
endpoint.response.responseType === 'resource' &&
endpoint.response.resourceType === 'action_attempt'
const returnsActionAttempt = isActionAttemptEndpoint(endpoint)

const methodName = camelCase(endpoint.name)

Expand Down Expand Up @@ -151,6 +155,10 @@ export const getEndpointLayoutContext = (
}
}

const isActionAttemptEndpoint = (endpoint: Endpoint): boolean =>
endpoint.response.responseType === 'resource' &&
endpoint.response.resourceType === 'action_attempt'

const getEndpointResponseResourceTypes = (endpoint: Endpoint): string[] => {
if (endpoint.response.responseType === 'void') return []
if (endpoint.response.responseType === 'resource') {
Expand Down
32 changes: 29 additions & 3 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ export default [
'unused-imports': unusedImports,
import: importPlugin,
},
settings: {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
project: './tsconfig.json',
},
},
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-import-type-side-effects': 'error',
Expand All @@ -31,9 +41,25 @@ export default [
fixStyle: 'inline-type-imports',
},
],
'import/extensions': ['error', 'ignorePackages'],
'import/no-duplicates': ['error', { 'prefer-inline': true }],
'import/no-relative-parent-imports': 'error',
'import/no-cycle': [
'error',
{
ignoreExternal: true,
},
],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['..', '../**'],
message:
'Import by path alias instead, e.g., lib/foo/bar.js or test/fixtures/blueprint.js.',
},
],
},
],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': [
'error',
Expand Down Expand Up @@ -61,7 +87,7 @@ export default [
['^node:'],
['^@?\\w'],
['@seamapi/http'],
['^lib/'],
['^lib/', '^test/'],
['^'],
['^\\.'],
],
Expand Down
Loading
Loading