diff --git a/.github/workflows/prune.yml b/.github/workflows/prune.yml new file mode 100644 index 00000000..562d16cc --- /dev/null +++ b/.github/workflows/prune.yml @@ -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 diff --git a/ava.config.js b/ava.config.js index 6a909976..3139f7a1 100644 --- a/ava.config.js +++ b/ava.config.js @@ -9,8 +9,8 @@ export default () => { return { files: ['**/*.test.ts', '!package/**/*'], - ignoreChanges: { - watchMode: ['tmp/**/*'], + watchMode: { + ignoreChanges: ['tmp/**/*'], }, extensions: ['ts'], nodeArguments: ['--import=tsx'], diff --git a/codegen/layouts/partials/route-class-endpoint.hbs b/codegen/layouts/partials/route-class-endpoint.hbs index 962e784f..707d31e3 100644 --- a/codegen/layouts/partials/route-class-endpoint.hbs +++ b/codegen/layouts/partials/route-class-endpoint.hbs @@ -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}} }) } diff --git a/codegen/layouts/partials/route-imports.hbs b/codegen/layouts/partials/route-imports.hbs index 9eab82c0..ffa773dc 100644 --- a/codegen/layouts/partials/route-imports.hbs +++ b/codegen/layouts/partials/route-imports.hbs @@ -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}} diff --git a/codegen/lib/layouts/route.ts b/codegen/lib/layouts/route.ts index c6882b25..4b251bd1 100644 --- a/codegen/lib/layouts/route.ts +++ b/codegen/lib/layouts/route.ts @@ -9,6 +9,7 @@ export interface RouteLayoutContext { endpoints: EndpointLayoutContext[] subroutes: SubrouteLayoutContext[] skipClientSessionImport: boolean + needsActionAttemptsImport: boolean resourceTypeImports: ResourceTypeImport[] } @@ -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 ? [ @@ -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) @@ -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') { diff --git a/eslint.config.ts b/eslint.config.ts index ed009197..77975224 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -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', @@ -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', @@ -61,7 +87,7 @@ export default [ ['^node:'], ['^@?\\w'], ['@seamapi/http'], - ['^lib/'], + ['^lib/', '^test/'], ['^'], ['^\\.'], ], diff --git a/package-lock.json b/package-lock.json index 6ae2f07a..d412b6cc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "concurrently": "^10.0.4", "del-cli": "^7.0.0", "eslint": "^9.31.0", + "eslint-import-resolver-typescript": "^4.4.5", "eslint-plugin-import": "^2.32.0", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unused-imports": "^4.1.4", @@ -44,7 +45,7 @@ }, "engines": { "node": ">=22.11.0", - "npm": ">=10.9.4" + "npm": ">=10.0.0" } }, "node_modules/@bcoe/v8-coverage": { @@ -67,6 +68,40 @@ "node": ">=20" } }, + "node_modules/@emnapi/core": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.10.0.tgz", + "integrity": "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.1", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.10.0.tgz", + "integrity": "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.28.1", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.1.tgz", @@ -875,6 +910,28 @@ "node": ">=18" } }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.2.tgz", + "integrity": "sha512-JfB4kuJQjaoHuCTseIINHtHWeJnvgEcxjwA5t/Y00ZgaOO1Crz3fjT/p8kT28zA/Caz7oiUMn3d6H2yOVCVwuw==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.3", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.3" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1165,6 +1222,17 @@ "eslint": ">=8.40.0" } }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.3.tgz", + "integrity": "sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@types/estree": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", @@ -1537,6 +1605,349 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/@unrs/resolver-binding-android-arm-eabi": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm-eabi/-/resolver-binding-android-arm-eabi-1.12.2.tgz", + "integrity": "sha512-g5T90pqg1bo/7mytQx6F4iBNC0Wsh9cu+z9veDbFjc7HjpesJFWD7QMS0NGStXM075+7dJPPVvBbpZlnrdpi/w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@unrs/resolver-binding-android-arm64": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-android-arm64/-/resolver-binding-android-arm64-1.12.2.tgz", + "integrity": "sha512-YGCRZv/9GLhwmz6mYDeTsm/92BAyR28l6c2ReweVW5pWgfsitWLY8upvfRlGdoyD8HjeTHSYJWyZGD4KJA/nFQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@unrs/resolver-binding-darwin-arm64": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-darwin-arm64/-/resolver-binding-darwin-arm64-1.12.2.tgz", + "integrity": "sha512-u9DiNT1auQMO20A9SyTuG3wUgQWB9Z7KjAg0uFuCDR1FsAY8A0CG2S6JpHS1xwm/w1G08bjXZDcyOCjv1WAm2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/resolver-binding-darwin-x64": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-darwin-x64/-/resolver-binding-darwin-x64-1.12.2.tgz", + "integrity": "sha512-f7rPLi/T1HVKZu/u6t87lroib16n8vrSzcyxI7lg4BGO9UF26KhQL44sd9eOUgrTYhvRXtWOIZT5PejdPyJfUA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@unrs/resolver-binding-freebsd-x64": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-freebsd-x64/-/resolver-binding-freebsd-x64-1.12.2.tgz", + "integrity": "sha512-BpcOjWCJub6nRZUS2zA20pmLvjtqAtGejETaIyRLiZiQf++cbrjltLA5NN/xaXfqeOBOSlMFbemIl5/S5tljmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm-gnueabihf": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-gnueabihf/-/resolver-binding-linux-arm-gnueabihf-1.12.2.tgz", + "integrity": "sha512-vZTDvdSISZjJx66OzJqtsOhzifbqRjbmI1Mnu49fQDwog5GtDI4QidRiEAYbZCRj9C8YZEW+3ZjqsyS9GR4k2A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm-musleabihf": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm-musleabihf/-/resolver-binding-linux-arm-musleabihf-1.12.2.tgz", + "integrity": "sha512-BiPI+IrIlwcW4nLLMM21+B1dFPzd55yAVgVGrdgDjNef+ch03GdxrcyaIz8X9SsQirh/kCQ7mviyWlMxdh2D7g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm64-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-gnu/-/resolver-binding-linux-arm64-gnu-1.12.2.tgz", + "integrity": "sha512-zJc0H99FEPoFfSrNpa91HYfxzfAJCr502oxNK1cfdC9hlaFI43RT+JFCann9JUgZmLzzntChHyn13Sgn9ljHNg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-arm64-musl": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-arm64-musl/-/resolver-binding-linux-arm64-musl-1.12.2.tgz", + "integrity": "sha512-KQ3Lki6l+Pz1k/eBipN41ES+YUK30beLGb9YqcB1O542cyLCNE6GaxrfcY3T6EezmGGk84wb5XyO9loTM9tkcA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-loong64-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-loong64-gnu/-/resolver-binding-linux-loong64-gnu-1.12.2.tgz", + "integrity": "sha512-3SJGEh1DborhG6pyxvhPzCT4bbSIVihsvgJc13P1bHG7KLdNDaF9T3gsTwFc7Jw/5Y5/iWOjkEx7Zy0NvCGX3Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-loong64-musl": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-loong64-musl/-/resolver-binding-linux-loong64-musl-1.12.2.tgz", + "integrity": "sha512-jiuG/Obbel7uw1PwHNFfrkiKhLAF6mnyZ6aWlOAVN9WqKm8v0OFGnciJIHu8+CMvXLQ8AD51LPzAoUfT21D5Ew==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-ppc64-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-ppc64-gnu/-/resolver-binding-linux-ppc64-gnu-1.12.2.tgz", + "integrity": "sha512-q7xRvVpmcfeL+LlZg8Pbbo6QaTZwDU5BaGZbwfhkEsXJn3Was8xYfE0RBH266xZt0rM6B7i8xAYIvjthuUIWHg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-riscv64-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-riscv64-gnu/-/resolver-binding-linux-riscv64-gnu-1.12.2.tgz", + "integrity": "sha512-0CVdx6lcnT3Q9inOH8tsMIOJ6ImndllMjqJHg8RLVdB7Vq4SfkEXl9mCSsVNuNA4MCYycRicCUxPCabVHJRr6A==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-riscv64-musl": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-riscv64-musl/-/resolver-binding-linux-riscv64-musl-1.12.2.tgz", + "integrity": "sha512-iOwlRo9vnp6R6ohHQS11n0NnfdXx/omhkocmIfaPRpQhKZ+3BDMkkdRVh53qjkFkpPddf+FETA28NwGN7l5l+w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-s390x-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-s390x-gnu/-/resolver-binding-linux-s390x-gnu-1.12.2.tgz", + "integrity": "sha512-HYJtLfXq94q8iZNFT1lknx258wlkkWhZeUXJRqzKBBUJ00CvZ+N33zgbCqimLjsyw5Va6uUxhVa12mI+kaveEw==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-x64-gnu": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-gnu/-/resolver-binding-linux-x64-gnu-1.12.2.tgz", + "integrity": "sha512-mPsUhunKKDih5O96Y6enDQyHc1SqBPlY1E/SfMWDM3EdJ95Z9CArPeCVwCCqbP45ljvivdEk8Fxn+SIb1rDAJQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-linux-x64-musl": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-linux-x64-musl/-/resolver-binding-linux-x64-musl-1.12.2.tgz", + "integrity": "sha512-azrt6+5ydLd8Vt210AAFis/lZevSfPw93EJRIJG+xPu4WCJ8K0kppCTpMyLPcKT7H15M4Jnt2tMp5bOvCkRC6A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@unrs/resolver-binding-openharmony-arm64": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-openharmony-arm64/-/resolver-binding-openharmony-arm64-1.12.2.tgz", + "integrity": "sha512-YZ9hP4O0X9PQb8eO980qmLNGH4zT3I9+SZTdt0Pr0YyuGQhYKoOZkV02VzrzyOZJ5xIJ3UFIenKkUkGg8GjgWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@unrs/resolver-binding-wasm32-wasi": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-wasm32-wasi/-/resolver-binding-wasm32-wasi-1.12.2.tgz", + "integrity": "sha512-tYFDIkMxSflfEc/h92ZWNsZlHSwgimbNHSO3PL2JWQHfCuC2q316jMyYU9TIWZsFK2bQwyK5VAdYgn8ygPj69A==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "1.10.0", + "@emnapi/runtime": "1.10.0", + "@napi-rs/wasm-runtime": "^1.1.4" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@unrs/resolver-binding-win32-arm64-msvc": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-arm64-msvc/-/resolver-binding-win32-arm64-msvc-1.12.2.tgz", + "integrity": "sha512-qzNyg3xL0VPQmCaUh+N5jSitce6k+uCBfMDesWRnlULOZaqUkaJ0ybdT+UqlAWJoQjuqfIU/0Ptx9bteN4D82g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@unrs/resolver-binding-win32-ia32-msvc": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-ia32-msvc/-/resolver-binding-win32-ia32-msvc-1.12.2.tgz", + "integrity": "sha512-WD9sY00OfpHVGfsnHZoA8jVT+esS/Bg8z8jzxp5BnDCjjwsuKsPQrzswwpFy4J1AUJbXPRfkpcX0mXrzeXW79g==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@unrs/resolver-binding-win32-x64-msvc": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@unrs/resolver-binding-win32-x64-msvc/-/resolver-binding-win32-x64-msvc-1.12.2.tgz", + "integrity": "sha512-nAB74NfSNKknqQ1RrYj6uz8FcXEomu/MATJZxh/x+BArzN2U3JbOYC0APYzUIGhVY3m5hRxA8VPNdPBoG8txlA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@vercel/nft": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/@vercel/nft/-/nft-1.10.2.tgz", @@ -3393,6 +3804,31 @@ "eslint": ">=6.0.0" } }, + "node_modules/eslint-import-context": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/eslint-import-context/-/eslint-import-context-0.1.9.tgz", + "integrity": "sha512-K9Hb+yRaGAGUbwjhFNHvSmmkZs9+zbuoe3kFQ4V1wYjrepUFYM2dZAfNtjbbj3qsPfUfsA68Bx/ICWQMi+C8Eg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-tsconfig": "^4.10.1", + "stable-hash-x": "^0.2.0" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-import-context" + }, + "peerDependencies": { + "unrs-resolver": "^1.0.0" + }, + "peerDependenciesMeta": { + "unrs-resolver": { + "optional": true + } + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.10", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.10.tgz", @@ -3415,6 +3851,41 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-import-resolver-typescript": { + "version": "4.4.5", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-4.4.5.tgz", + "integrity": "sha512-nbE5XLph6TLtGYcu/U6e6ZVXyKBhbDWK5cLGk76eJ7NdZpwf1P9EFkpt1Z01mNZNrrilsAYWKH6zUkL4reoXbw==", + "dev": true, + "license": "ISC", + "dependencies": { + "debug": "^4.4.1", + "eslint-import-context": "^0.1.8", + "get-tsconfig": "^4.10.1", + "is-bun-module": "^2.0.0", + "stable-hash-x": "^0.2.0", + "tinyglobby": "^0.2.14", + "unrs-resolver": "^1.7.11" + }, + "engines": { + "node": "^16.17.0 || >=18.6.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-import-resolver-typescript" + }, + "peerDependencies": { + "eslint": "*", + "eslint-plugin-import": "*", + "eslint-plugin-import-x": "*" + }, + "peerDependenciesMeta": { + "eslint-plugin-import": { + "optional": true + }, + "eslint-plugin-import-x": { + "optional": true + } + } + }, "node_modules/eslint-module-utils": { "version": "2.14.0", "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.14.0.tgz", @@ -5033,6 +5504,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-bun-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-2.0.0.tgz", + "integrity": "sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.7.1" + } + }, "node_modules/is-callable": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", @@ -6422,6 +6903,22 @@ "url": "https://github.com/sponsors/raouldeheer" } }, + "node_modules/napi-postinstall": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/napi-postinstall/-/napi-postinstall-0.3.4.tgz", + "integrity": "sha512-PHI5f1O0EP5xJ9gQmFGMS6IZcrVvTjpXjz7Na41gTE7eE2hK11lg04CECCYEEjdc17EV4DO+fkGEtt7TpTaTiQ==", + "dev": true, + "license": "MIT", + "bin": { + "napi-postinstall": "lib/cli.js" + }, + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/napi-postinstall" + } + }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -7992,6 +8489,16 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/stable-hash-x": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/stable-hash-x/-/stable-hash-x-0.2.0.tgz", + "integrity": "sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/stack-utils": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.6.tgz", @@ -8932,6 +9439,44 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/unrs-resolver": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/unrs-resolver/-/unrs-resolver-1.12.2.tgz", + "integrity": "sha512-dmlRxBJJayXjqTwC+JtF1HhJmgf3ftQ3YejFcZrf4+KKtJv0qDsK1pjqaaVjG7wJ5NJ6UVP1OqRMQ71Z4C3rxQ==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "napi-postinstall": "^0.3.4" + }, + "funding": { + "url": "https://opencollective.com/unrs-resolver" + }, + "optionalDependencies": { + "@unrs/resolver-binding-android-arm-eabi": "1.12.2", + "@unrs/resolver-binding-android-arm64": "1.12.2", + "@unrs/resolver-binding-darwin-arm64": "1.12.2", + "@unrs/resolver-binding-darwin-x64": "1.12.2", + "@unrs/resolver-binding-freebsd-x64": "1.12.2", + "@unrs/resolver-binding-linux-arm-gnueabihf": "1.12.2", + "@unrs/resolver-binding-linux-arm-musleabihf": "1.12.2", + "@unrs/resolver-binding-linux-arm64-gnu": "1.12.2", + "@unrs/resolver-binding-linux-arm64-musl": "1.12.2", + "@unrs/resolver-binding-linux-loong64-gnu": "1.12.2", + "@unrs/resolver-binding-linux-loong64-musl": "1.12.2", + "@unrs/resolver-binding-linux-ppc64-gnu": "1.12.2", + "@unrs/resolver-binding-linux-riscv64-gnu": "1.12.2", + "@unrs/resolver-binding-linux-riscv64-musl": "1.12.2", + "@unrs/resolver-binding-linux-s390x-gnu": "1.12.2", + "@unrs/resolver-binding-linux-x64-gnu": "1.12.2", + "@unrs/resolver-binding-linux-x64-musl": "1.12.2", + "@unrs/resolver-binding-openharmony-arm64": "1.12.2", + "@unrs/resolver-binding-wasm32-wasi": "1.12.2", + "@unrs/resolver-binding-win32-arm64-msvc": "1.12.2", + "@unrs/resolver-binding-win32-ia32-msvc": "1.12.2", + "@unrs/resolver-binding-win32-x64-msvc": "1.12.2" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", diff --git a/package.json b/package.json index 2282993e..fe99c92b 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ }, "engines": { "node": ">=22.11.0", - "npm": ">=10.9.4" + "npm": ">=10.0.0" }, "devEngines": { "runtime": { @@ -78,7 +78,7 @@ }, "packageManager": { "name": "npm", - "version": "^11.12.0 || ^10.9.4" + "version": "^11.0.0 || ^10.0.0" } }, "dependencies": { @@ -99,6 +99,7 @@ "concurrently": "^10.0.4", "del-cli": "^7.0.0", "eslint": "^9.31.0", + "eslint-import-resolver-typescript": "^4.4.5", "eslint-plugin-import": "^2.32.0", "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unused-imports": "^4.1.4", diff --git a/src/lib/seam/connect/auth.ts b/src/lib/seam/connect/auth.ts index 606ec410..183aa458 100644 --- a/src/lib/seam/connect/auth.ts +++ b/src/lib/seam/connect/auth.ts @@ -6,14 +6,15 @@ import { isSeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken, isSeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken, SeamHttpInvalidOptionsError, + type SeamHttpOptions, type SeamHttpOptionsWithApiKey, type SeamHttpOptionsWithClientSessionToken, type SeamHttpOptionsWithConsoleSessionToken, type SeamHttpOptionsWithPersonalAccessToken, + type SeamHttpWithoutWorkspaceOptions, type SeamHttpWithoutWorkspaceOptionsWithConsoleSessionToken, type SeamHttpWithoutWorkspaceOptionsWithPersonalAccessToken, } from './options.js' -import type { Options } from './parse-options.js' import { accessTokenPrefix, clientSessionTokenPrefix, @@ -28,6 +29,9 @@ import { } from './token.js' type Headers = Record +type Options = + | SeamHttpWithoutWorkspaceOptions + | (SeamHttpOptions & { publishableKey?: string }) export const getAuthHeaders = (options: Options): Headers => { if ('publishableKey' in options && options.publishableKey != null) { diff --git a/src/lib/seam/connect/options.ts b/src/lib/seam/connect/options.ts index 2594ceca..a91807f9 100644 --- a/src/lib/seam/connect/options.ts +++ b/src/lib/seam/connect/options.ts @@ -1,6 +1,10 @@ import type { Client, ClientOptions } from './client.js' -import { isSeamHttpRequestOption } from './parse-options.js' -import type { ResolveActionAttemptOptions } from './resolve-action-attempt.js' +import { + isSeamHttpRequestOption, + type SeamHttpRequestOptions, +} from './request-options.js' + +export type { SeamHttpRequestOptions } from './request-options.js' export type SeamHttpWithoutWorkspaceOptions = | SeamHttpWithoutWorkspaceOptionsFromEnv @@ -20,10 +24,6 @@ interface SeamHttpCommonOptions extends ClientOptions, SeamHttpRequestOptions { endpoint?: string } -export interface SeamHttpRequestOptions { - waitForActionAttempt?: boolean | ResolveActionAttemptOptions -} - export interface SeamHttpFromPublishableKeyOptions extends SeamHttpCommonOptions {} export interface SeamHttpOptionsFromEnv extends SeamHttpCommonOptions {} diff --git a/src/lib/seam/connect/parse-options.ts b/src/lib/seam/connect/parse-options.ts index 4c94b620..0b08a2a9 100644 --- a/src/lib/seam/connect/parse-options.ts +++ b/src/lib/seam/connect/parse-options.ts @@ -12,6 +12,7 @@ import { type SeamHttpRequestOptions, type SeamHttpWithoutWorkspaceOptions, } from './options.js' +import { isSeamHttpRequestOption } from './request-options.js' export const defaultEndpoint = 'https://connect.getseam.com' @@ -177,11 +178,4 @@ export const limitToSeamHttpRequestOptions = ( ) as Required } -export const isSeamHttpRequestOption = ( - key: string, -): key is keyof SeamHttpRequestOptions => { - const keys: Record = { - waitForActionAttempt: true, - } - return Object.keys(keys).includes(key) -} +export { isSeamHttpRequestOption } from './request-options.js' diff --git a/src/lib/seam/connect/request-options.ts b/src/lib/seam/connect/request-options.ts new file mode 100644 index 00000000..e403a4f7 --- /dev/null +++ b/src/lib/seam/connect/request-options.ts @@ -0,0 +1,14 @@ +import type { ResolveActionAttemptOptions } from './resolve-action-attempt.js' + +export interface SeamHttpRequestOptions { + waitForActionAttempt?: boolean | ResolveActionAttemptOptions +} + +export const isSeamHttpRequestOption = ( + key: string, +): key is keyof SeamHttpRequestOptions => { + const keys: Record = { + waitForActionAttempt: true, + } + return Object.keys(keys).includes(key) +} diff --git a/src/lib/seam/connect/resolve-action-attempt.ts b/src/lib/seam/connect/resolve-action-attempt.ts index 49d1ae9e..3064d511 100644 --- a/src/lib/seam/connect/resolve-action-attempt.ts +++ b/src/lib/seam/connect/resolve-action-attempt.ts @@ -1,5 +1,8 @@ import type { ActionAttempt } from './resources/action-attempt.js' -import type { SeamHttpActionAttempts } from './routes/index.js' + +export interface ActionAttemptsClient { + get(parameters: { action_attempt_id: string }): PromiseLike +} export interface ResolveActionAttemptOptions { timeout?: number @@ -8,7 +11,7 @@ export interface ResolveActionAttemptOptions { export const resolveActionAttempt = async ( actionAttempt: T, - actionAttempts: SeamHttpActionAttempts, + actionAttempts: ActionAttemptsClient, { timeout = 10_000, pollingInterval = 1_000 }: ResolveActionAttemptOptions, ): Promise> => { let timeoutRef @@ -32,7 +35,7 @@ export const resolveActionAttempt = async ( const pollActionAttempt = async ( actionAttempt: T, - actionAttempts: SeamHttpActionAttempts, + actionAttempts: ActionAttemptsClient, options: Pick, ): Promise> => { if (isSuccessfulActionAttempt(actionAttempt)) { diff --git a/src/lib/seam/connect/routes/access-methods/access-methods.ts b/src/lib/seam/connect/routes/access-methods/access-methods.ts index 400f47af..5faf9729 100644 --- a/src/lib/seam/connect/routes/access-methods/access-methods.ts +++ b/src/lib/seam/connect/routes/access-methods/access-methods.ts @@ -32,6 +32,7 @@ import { import type { AccessMethod } from 'lib/seam/connect/resources/access-method.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' import type { Batch } from 'lib/seam/connect/resources/batch.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -182,6 +183,10 @@ export class SeamHttpAccessMethods { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -214,6 +219,10 @@ export class SeamHttpAccessMethods { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -278,6 +287,10 @@ export class SeamHttpAccessMethods { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/acs/encoders/encoders.ts b/src/lib/seam/connect/routes/acs/encoders/encoders.ts index 82d90360..5f66f3e4 100644 --- a/src/lib/seam/connect/routes/acs/encoders/encoders.ts +++ b/src/lib/seam/connect/routes/acs/encoders/encoders.ts @@ -31,6 +31,7 @@ import { } from 'lib/seam/connect/parse-options.js' import type { AcsEncoder } from 'lib/seam/connect/resources/acs-encoder.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -181,6 +182,10 @@ export class SeamHttpAcsEncoders { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -229,6 +234,10 @@ export class SeamHttpAcsEncoders { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -245,6 +254,10 @@ export class SeamHttpAcsEncoders { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/acs/entrances/entrances.ts b/src/lib/seam/connect/routes/acs/entrances/entrances.ts index 3c8918a0..411546cd 100644 --- a/src/lib/seam/connect/routes/acs/entrances/entrances.ts +++ b/src/lib/seam/connect/routes/acs/entrances/entrances.ts @@ -32,6 +32,7 @@ import { import type { AcsCredential } from 'lib/seam/connect/resources/acs-credential.js' import type { AcsEntrance } from 'lib/seam/connect/resources/acs-entrance.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -240,6 +241,10 @@ export class SeamHttpAcsEntrances { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/action-attempts/action-attempts.ts b/src/lib/seam/connect/routes/action-attempts/action-attempts.ts index e1993c51..f64fabcc 100644 --- a/src/lib/seam/connect/routes/action-attempts/action-attempts.ts +++ b/src/lib/seam/connect/routes/action-attempts/action-attempts.ts @@ -174,6 +174,10 @@ export class SeamHttpActionAttempts { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } diff --git a/src/lib/seam/connect/routes/locks/locks.ts b/src/lib/seam/connect/routes/locks/locks.ts index c75918ae..ac91fb2d 100644 --- a/src/lib/seam/connect/routes/locks/locks.ts +++ b/src/lib/seam/connect/routes/locks/locks.ts @@ -31,6 +31,7 @@ import { } from 'lib/seam/connect/parse-options.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' import type { Device } from 'lib/seam/connect/resources/device.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -181,6 +182,10 @@ export class SeamHttpLocks { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -230,6 +235,10 @@ export class SeamHttpLocks { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -246,6 +255,10 @@ export class SeamHttpLocks { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/locks/simulate/simulate.ts b/src/lib/seam/connect/routes/locks/simulate/simulate.ts index 34210e47..c3b1f1ab 100644 --- a/src/lib/seam/connect/routes/locks/simulate/simulate.ts +++ b/src/lib/seam/connect/routes/locks/simulate/simulate.ts @@ -30,6 +30,7 @@ import { parseOptions, } from 'lib/seam/connect/parse-options.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -174,6 +175,10 @@ export class SeamHttpLocksSimulate { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -190,6 +195,10 @@ export class SeamHttpLocksSimulate { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/thermostats/daily-programs/daily-programs.ts b/src/lib/seam/connect/routes/thermostats/daily-programs/daily-programs.ts index 6e5f43ea..4d8dfc3f 100644 --- a/src/lib/seam/connect/routes/thermostats/daily-programs/daily-programs.ts +++ b/src/lib/seam/connect/routes/thermostats/daily-programs/daily-programs.ts @@ -31,6 +31,7 @@ import { } from 'lib/seam/connect/parse-options.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' import type { ThermostatDailyProgram } from 'lib/seam/connect/resources/thermostat-daily-program.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -210,6 +211,10 @@ export class SeamHttpThermostatsDailyPrograms { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/thermostats/thermostats.ts b/src/lib/seam/connect/routes/thermostats/thermostats.ts index 34e91dd6..6f8c41b8 100644 --- a/src/lib/seam/connect/routes/thermostats/thermostats.ts +++ b/src/lib/seam/connect/routes/thermostats/thermostats.ts @@ -31,6 +31,7 @@ import { } from 'lib/seam/connect/parse-options.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' import type { Device } from 'lib/seam/connect/resources/device.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -194,6 +195,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -210,6 +215,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -258,6 +267,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -274,6 +287,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -306,6 +323,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -338,6 +359,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -354,6 +379,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } @@ -402,6 +431,10 @@ export class SeamHttpThermostats { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } } diff --git a/src/lib/seam/connect/routes/workspaces/workspaces.ts b/src/lib/seam/connect/routes/workspaces/workspaces.ts index 922bdcf6..2552f360 100644 --- a/src/lib/seam/connect/routes/workspaces/workspaces.ts +++ b/src/lib/seam/connect/routes/workspaces/workspaces.ts @@ -31,6 +31,7 @@ import { } from 'lib/seam/connect/parse-options.js' import type { ActionAttempt } from 'lib/seam/connect/resources/action-attempt.js' import type { Workspace } from 'lib/seam/connect/resources/workspace.js' +import { SeamHttpActionAttempts } from 'lib/seam/connect/routes/action-attempts/index.js' import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js' import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js' import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js' @@ -223,6 +224,10 @@ export class SeamHttpWorkspaces { body: parameters, responseKey: 'action_attempt', options, + actionAttempts: SeamHttpActionAttempts.fromClient(this.client, { + ...this.defaults, + waitForActionAttempt: false, + }), }) } diff --git a/src/lib/seam/connect/seam-http-request.ts b/src/lib/seam/connect/seam-http-request.ts index f83190af..bd2cb388 100644 --- a/src/lib/seam/connect/seam-http-request.ts +++ b/src/lib/seam/connect/seam-http-request.ts @@ -3,9 +3,11 @@ import type { Method } from 'axios' import type { Client } from './client.js' import type { SeamHttpRequestOptions } from './options.js' -import { resolveActionAttempt } from './resolve-action-attempt.js' +import { + type ActionAttemptsClient, + resolveActionAttempt, +} from './resolve-action-attempt.js' import type { ActionAttempt } from './resources/action-attempt.js' -import { SeamHttpActionAttempts } from './routes/index.js' interface SeamHttpRequestParent { readonly client: Client @@ -19,6 +21,7 @@ interface SeamHttpRequestConfig { readonly params?: undefined | Record readonly responseKey: TResponseKey readonly options?: Pick + readonly actionAttempts?: ActionAttemptsClient } export class SeamHttpRequest< @@ -101,12 +104,14 @@ export class SeamHttpRequest< this.#parent.defaults.waitForActionAttempt if (waitForActionAttempt !== false) { + if (this.#config.actionAttempts == null) { + throw new Error( + 'Cannot wait for an action attempt without an action attempts client', + ) + } const actionAttempt = await resolveActionAttempt( data as unknown as ActionAttempt, - SeamHttpActionAttempts.fromClient(this.#parent.client, { - ...this.#parent.defaults, - waitForActionAttempt: false, - }), + this.#config.actionAttempts, typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt, ) return actionAttempt as Response