From 0190d24e2d458545d2143d4214ea8cadb8a20308 Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 15:52:26 +0300 Subject: [PATCH 1/8] chore: add git flow --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 53 ++++++++++++++++++++++++++++++ .github/workflows/semantics.yml | 43 ++++++++++++++++++++++++ .releaserc.json | 16 +++++++++ CHANGELOG.md | 3 ++ 5 files changed, 173 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/semantics.yml create mode 100644 .releaserc.json create mode 100644 CHANGELOG.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2a9a7b9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,58 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # -------- pnpm + cache ---------- + - uses: pnpm/action-setup@v4 # installs pnpm (reads version from package.json if present) + - uses: actions/setup-node@v4 + with: + node-version: 20 # single version is fine for lint + cache: 'pnpm' # enables automatic pnpm-store caching + + - run: pnpm install --frozen-lockfile + - run: pnpm run lint + + build: + needs: lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [18.x, 20.x, 22.x] # stable Node versions + steps: + - uses: actions/checkout@v4 + + # -------- pnpm + cache ---------- + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - run: pnpm install --frozen-lockfile + - run: pnpm run build + + test: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + # -------- pnpm + cache ---------- + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - run: pnpm install --frozen-lockfile + - run: pnpm run test \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b57839f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +on: + workflow_dispatch: # manual trigger + push: + branches: [master] # assumes your main branch is master + +concurrency: + group: release # never run two releases in parallel + cancel-in-progress: true + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write # needed for pushing version commits & creating releases + issues: write # needed for commenting on issues + pull-requests: write # needed for commenting on PRs + id-token: write # needed for npm provenance + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # semantic-release needs full history & tags + persist-credentials: false # use GitHub token with correct permissions + + # -------- pnpm + node (same cache strategy used in CI) ---- + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' + provenance: true + + - run: pnpm install --frozen-lockfile + + # (optional) run tests / build again for extra safety + - run: pnpm run test + - run: pnpm run build + + # -------- install semantic-release and plugins -------- + - name: Install semantic-release + run: pnpm add -D semantic-release @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits + + # -------- run release -------- + - name: Run semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true + run: npx semantic-release \ No newline at end of file diff --git a/.github/workflows/semantics.yml b/.github/workflows/semantics.yml new file mode 100644 index 0000000..5986848 --- /dev/null +++ b/.github/workflows/semantics.yml @@ -0,0 +1,43 @@ +name: PR Semantics + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + semantics: + name: Semantics + runs-on: ubuntu-latest + steps: + - uses: 8BitJonny/gh-get-current-pr@2.2.0 + id: pull-request + with: + sha: ${{ github.head_ref }} + + - name: Add Commit Lint + if: ${{ steps.pull-request.outputs.pr_found == 'true' }} + run: | + npm init -y + npm install --save-dev @commitlint/cli @commitlint/config-angular + echo "module.exports = { \ + extends: ['@commitlint/config-angular'], \ + rules: { \ + 'subject-empty': [2, 'never'], \ + 'scope-empty' : [2, 'never'], \ + 'type-case' : [2, 'always', 'lower-case'], \ + 'type-empty' : [2, 'never'], \ + 'type-enum' : [2, 'always', ['chore','feat','fix','refactor']], \ + 'scope-enum' : [2, 'always', ['openapi']] \ + } \ + };" > commitlint.config.js + + - name: Validate Semantic Title + if: ${{ steps.pull-request.outputs.pr_found == 'true' }} + run: | + echo "${{ steps.pull-request.outputs.pr_title }}" | npx commitlint + + - name: Get Semantic Commit Scope + if: ${{ steps.pull-request.outputs.pr_found == 'true' }} + id: scope + run: | + echo "name=$(echo '${{ steps.pull-request.outputs.pr_title }}' | cut -d'(' -f1)" >> $GITHUB_OUTPUT \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..c7fc8f9 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,16 @@ +{ + "branches": ["master"], + "plugins": [ + "@semantic-release/commit-analyzer", + ["@semantic-release/release-notes-generator", { "preset": "conventionalcommits" }], + "@semantic-release/changelog", + ["@semantic-release/npm", { + "provenance": true + }], + ["@semantic-release/git", { + "assets": ["CHANGELOG.md", "package.json", "pnpm-lock.yaml"], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + }], + "@semantic-release/github" + ] +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..19c6575 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. \ No newline at end of file From 08fd7feac867c54571162f3687ee74304da5379e Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 15:55:56 +0300 Subject: [PATCH 2/8] fix --- .github/workflows/ci.yml | 7 +++---- .github/workflows/release.yml | 15 +++++---------- .github/workflows/semantics.yml | 20 +++++++------------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a9a7b9..0626aaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,9 @@ -name: CI +name: Continuous Integration / Pull Request on: - push: - branches: [master] pull_request: - branches: [master] + branches: + - master jobs: lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b57839f..e138ec7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,12 +1,10 @@ name: Release on: - workflow_dispatch: # manual trigger - push: - branches: [master] # assumes your main branch is master + workflow_dispatch: concurrency: - group: release # never run two releases in parallel + group: release cancel-in-progress: true jobs: @@ -21,10 +19,9 @@ jobs: steps: - uses: actions/checkout@v4 with: - fetch-depth: 0 # semantic-release needs full history & tags - persist-credentials: false # use GitHub token with correct permissions + fetch-depth: 0 + persist-credentials: false - # -------- pnpm + node (same cache strategy used in CI) ---- - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: @@ -35,15 +32,13 @@ jobs: - run: pnpm install --frozen-lockfile - # (optional) run tests / build again for extra safety - run: pnpm run test + - run: pnpm run build - # -------- install semantic-release and plugins -------- - name: Install semantic-release run: pnpm add -D semantic-release @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits - # -------- run release -------- - name: Run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/semantics.yml b/.github/workflows/semantics.yml index 5986848..7ed0e79 100644 --- a/.github/workflows/semantics.yml +++ b/.github/workflows/semantics.yml @@ -1,8 +1,9 @@ -name: PR Semantics +name: Pull Request Semantics on: pull_request: - types: [opened, edited, reopened, synchronize] + branches: + - master jobs: semantics: @@ -23,11 +24,10 @@ jobs: extends: ['@commitlint/config-angular'], \ rules: { \ 'subject-empty': [2, 'never'], \ - 'scope-empty' : [2, 'never'], \ - 'type-case' : [2, 'always', 'lower-case'], \ - 'type-empty' : [2, 'never'], \ - 'type-enum' : [2, 'always', ['chore','feat','fix','refactor']], \ - 'scope-enum' : [2, 'always', ['openapi']] \ + 'scope-empty': [0, 'never'], \ + 'type-case': [2, 'always', 'lower-case'], \ + 'type-empty': [2, 'never'], \ + 'type-enum': [2, 'always', ['chore','feat','fix','refactor']] \ } \ };" > commitlint.config.js @@ -35,9 +35,3 @@ jobs: if: ${{ steps.pull-request.outputs.pr_found == 'true' }} run: | echo "${{ steps.pull-request.outputs.pr_title }}" | npx commitlint - - - name: Get Semantic Commit Scope - if: ${{ steps.pull-request.outputs.pr_found == 'true' }} - id: scope - run: | - echo "name=$(echo '${{ steps.pull-request.outputs.pr_title }}' | cut -d'(' -f1)" >> $GITHUB_OUTPUT \ No newline at end of file From 613f017fb47229caf6221ace3531901a4e663d3e Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 15:58:41 +0300 Subject: [PATCH 3/8] chore(ci): fix workflow configuration issues --- .github/workflows/ci.yml | 12 +++++++++--- .github/workflows/release.yml | 2 ++ .github/workflows/semantics.yml | 25 +++++++++++++------------ 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0626aaa..2d5b850 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,13 @@ jobs: - uses: actions/checkout@v4 # -------- pnpm + cache ---------- - - uses: pnpm/action-setup@v4 # installs pnpm (reads version from package.json if present) + - uses: pnpm/action-setup@v4 + with: + version: 8 # Specify pnpm version (adjust to your preferred version) - uses: actions/setup-node@v4 with: - node-version: 20 # single version is fine for lint - cache: 'pnpm' # enables automatic pnpm-store caching + node-version: 20 + cache: 'pnpm' - run: pnpm install --frozen-lockfile - run: pnpm run lint @@ -32,6 +34,8 @@ jobs: # -------- pnpm + cache ---------- - uses: pnpm/action-setup@v4 + with: + version: 8 # Specify pnpm version - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} @@ -48,6 +52,8 @@ jobs: # -------- pnpm + cache ---------- - uses: pnpm/action-setup@v4 + with: + version: 8 # Specify pnpm version - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e138ec7..e9c453c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,8 @@ jobs: persist-credentials: false - uses: pnpm/action-setup@v4 + with: + version: 8 # Specify pnpm version - uses: actions/setup-node@v4 with: node-version: 20 diff --git a/.github/workflows/semantics.yml b/.github/workflows/semantics.yml index 7ed0e79..25c5169 100644 --- a/.github/workflows/semantics.yml +++ b/.github/workflows/semantics.yml @@ -9,17 +9,20 @@ jobs: semantics: name: Semantics runs-on: ubuntu-latest + permissions: + pull-requests: read + contents: read steps: - - uses: 8BitJonny/gh-get-current-pr@2.2.0 - id: pull-request - with: - sha: ${{ github.head_ref }} - - - name: Add Commit Lint - if: ${{ steps.pull-request.outputs.pr_found == 'true' }} + - name: Validate PR Title run: | + PR_TITLE="${{ github.event.pull_request.title }}" + echo "Validating PR title: $PR_TITLE" + + # Install commitlint npm init -y npm install --save-dev @commitlint/cli @commitlint/config-angular + + # Configure commitlint echo "module.exports = { \ extends: ['@commitlint/config-angular'], \ rules: { \ @@ -30,8 +33,6 @@ jobs: 'type-enum': [2, 'always', ['chore','feat','fix','refactor']] \ } \ };" > commitlint.config.js - - - name: Validate Semantic Title - if: ${{ steps.pull-request.outputs.pr_found == 'true' }} - run: | - echo "${{ steps.pull-request.outputs.pr_title }}" | npx commitlint + + # Validate title + echo "$PR_TITLE" | npx commitlint From 5e0ba9863bfb8c199da570cafdac557e5d0d892f Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 16:01:03 +0300 Subject: [PATCH 4/8] fix(ci): handle missing lock file in CI workflows --- .github/workflows/ci.yml | 23 +++++++++++++++++++---- .github/workflows/release.yml | 4 +++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d5b850..5659431 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # -------- pnpm + cache ---------- - uses: pnpm/action-setup@v4 @@ -20,7 +22,10 @@ jobs: node-version: 20 cache: 'pnpm' - - run: pnpm install --frozen-lockfile + # Try with --frozen-lockfile first, fallback to regular install if it fails + - name: Install dependencies + run: pnpm install --frozen-lockfile || pnpm install + - run: pnpm run lint build: @@ -28,9 +33,11 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x, 20.x, 22.x] # stable Node versions + node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # -------- pnpm + cache ---------- - uses: pnpm/action-setup@v4 @@ -41,7 +48,10 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'pnpm' - - run: pnpm install --frozen-lockfile + # Try with --frozen-lockfile first, fallback to regular install if it fails + - name: Install dependencies + run: pnpm install --frozen-lockfile || pnpm install + - run: pnpm run build test: @@ -49,6 +59,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # -------- pnpm + cache ---------- - uses: pnpm/action-setup@v4 @@ -59,5 +71,8 @@ jobs: node-version: 20 cache: 'pnpm' - - run: pnpm install --frozen-lockfile + # Try with --frozen-lockfile first, fallback to regular install if it fails + - name: Install dependencies + run: pnpm install --frozen-lockfile || pnpm install + - run: pnpm run test \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e9c453c..7621472 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,7 +32,9 @@ jobs: registry-url: 'https://registry.npmjs.org' provenance: true - - run: pnpm install --frozen-lockfile + # Try with --frozen-lockfile first, fallback to regular install if it fails + - name: Install dependencies + run: pnpm install --frozen-lockfile || pnpm install - run: pnpm run test From 350f545fbf8a1b38284fd4c411909e0eb220def2 Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 16:02:35 +0300 Subject: [PATCH 5/8] fix lint --- test/utils/index.ts | 2 +- test/utils/response-helpers.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/utils/index.ts b/test/utils/index.ts index 169cb6f..0f2842a 100644 --- a/test/utils/index.ts +++ b/test/utils/index.ts @@ -1 +1 @@ -export * from './response-helpers'; \ No newline at end of file +export * from './response-helpers'; diff --git a/test/utils/response-helpers.ts b/test/utils/response-helpers.ts index 18b2f66..8b22414 100644 --- a/test/utils/response-helpers.ts +++ b/test/utils/response-helpers.ts @@ -1,4 +1,4 @@ -import { ErrorCode } from '../../src'; +import { ErrorCode } from '../../src/http/schemas'; /** * Helper to create a success response envelope @@ -55,4 +55,4 @@ export function createErrorResponse(error: { } return response; -} \ No newline at end of file +} From c94c46eeb475cae00f230505ed9823e7379fb1ec Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 16:04:32 +0300 Subject: [PATCH 6/8] chore(ci): improve workflow with parallel jobs and better naming --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5659431..58cd3ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: jobs: lint: + name: Lint Code runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,10 +27,11 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile || pnpm install - - run: pnpm run lint + - name: Run ESLint + run: pnpm run lint build: - needs: lint + name: Build (Node ${{ matrix.node-version }}) runs-on: ubuntu-latest strategy: matrix: @@ -52,10 +54,11 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile || pnpm install - - run: pnpm run build + - name: Build SDK + run: pnpm run build test: - needs: build + name: Run Tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -75,4 +78,5 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile || pnpm install - - run: pnpm run test \ No newline at end of file + - name: Run Jest tests + run: pnpm run test \ No newline at end of file From c0fd03ac1dc355027fe9d7a39e48f9e912853690 Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 16:04:37 +0300 Subject: [PATCH 7/8] semantics --- .github/workflows/semantics.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/semantics.yml b/.github/workflows/semantics.yml index 25c5169..ebf2f04 100644 --- a/.github/workflows/semantics.yml +++ b/.github/workflows/semantics.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - master + types: [opened, edited, reopened, synchronize] jobs: semantics: From ebfce72c12ebc9c50d51f8bdfcf70131e7f6e1fd Mon Sep 17 00:00:00 2001 From: omermorad Date: Sun, 18 May 2025 16:06:42 +0300 Subject: [PATCH 8/8] remove test --- test/integration/deployments.real.int.test.ts | 152 ------------------ 1 file changed, 152 deletions(-) delete mode 100644 test/integration/deployments.real.int.test.ts diff --git a/test/integration/deployments.real.int.test.ts b/test/integration/deployments.real.int.test.ts deleted file mode 100644 index e413bd6..0000000 --- a/test/integration/deployments.real.int.test.ts +++ /dev/null @@ -1,152 +0,0 @@ -// import * as nock from 'nock'; // Removed nock -import { v4 as uuidv4 } from 'uuid'; -import { ApiError, AuthError, OpenApiSource, SpecInvalidError, TadataNodeSDK } from '../../src'; - -// More realistic OpenAPI spec with a path -const validOpenApiSpec = { - openapi: '3.0.0', - info: { - title: 'Test API', - version: '1.0.0', - }, - paths: { - '/test': { - get: { - summary: 'Test endpoint', - responses: { - '200': { - description: 'OK', - }, - }, - }, - }, - }, -}; - -const invalidOpenApiSpec = { - info: { - title: 'Test API', - version: '1.0.0', - }, - paths: {}, -}; - -// Use your real API key here (this is an example, replace with your actual key) -const REAL_API_KEY = 'fc2b51fef0f646aabe533f895a58ec64a61bdb77fbd81693f908339d2312cb7e'; -const INVALID_API_KEY = 'invalid_api_key'; - -// Can remove this constant since it's not needed anymore -// const MOCKED_DEPLOYMENT_NAME = 'Mocked Test API Service'; - -describe('Deployments Integration Test (Real Backend)', () => { - // Extend timeout for real API calls - jest.setTimeout(60000); - - const sdk = new TadataNodeSDK({ - apiKey: REAL_API_KEY, - }); - - const invalidSdk = new TadataNodeSDK({ - apiKey: INVALID_API_KEY, - }); - - // Removed nock related beforeAll, afterEach, afterAll - - // First test to verify backend connection is working - it('should verify backend is running by rejecting invalid credentials', async () => { - const source = OpenApiSource.fromObject(validOpenApiSpec); - - await expect( - invalidSdk.mcp.deploy({ - spec: source, - name: 'Auth Test', - }) - ).rejects.toThrow(AuthError); - }); - - describe('when deploying an OpenAPI spec', () => { - it('should successfully deploy an MCP server', async () => { - const source = OpenApiSource.fromObject(validOpenApiSpec); - - const result = await sdk.mcp.deploy({ - spec: source, - name: `Test API Service ${uuidv4()}`, - specBaseUrl: 'https://example.com/api', - }); - - // Validate the response structure - expect(result).toBeDefined(); - expect(result.id).toBeDefined(); - expect(result.specVersion).toBeDefined(); - expect(result.createdAt).toBeInstanceOf(Date); - - const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; - expect(uuidRegex.test(result.id)).toBe(true); - }); - - it('should throw SpecInvalidError for invalid OpenAPI specs before making API call', () => { - expect(() => OpenApiSource.fromObject(invalidOpenApiSpec)).toThrow(SpecInvalidError); - }); - - it('should throw AuthError when using incorrect API key', async () => { - const source = OpenApiSource.fromObject(validOpenApiSpec); - - await expect( - invalidSdk.mcp.deploy({ - spec: source, - name: 'Auth Test Service (Real Backend)', - }) - ).rejects.toThrow(AuthError); - }); - - it('should throw ApiError for backend validation failures', async () => { - // Using a spec that should trigger validation failures on the backend - const invalidSource = OpenApiSource.fromObject({ - openapi: '3.0.0', - info: { title: 'Invalid API Spec', version: '1.0.0' }, - // Empty paths object with no endpoints - paths: {}, - }); - - await expect( - sdk.mcp.deploy({ - spec: invalidSource, - name: 'Backend Validation Error Test', - }) - ).rejects.toThrow(ApiError); - }); - - it('should throw SpecInvalidError for malformed request body', async () => { - const source = OpenApiSource.fromObject(validOpenApiSpec); - - await expect( - sdk.mcp.deploy({ - spec: source, - // @ts-expect-error - intentionally passing wrong type for testing - name: 12345, - }) - ).rejects.toThrow(SpecInvalidError); - }); - - it('should throw ApiError for not found errors (404)', async () => { - const source = OpenApiSource.fromObject(validOpenApiSpec); - - // To trigger a 404, we need to hit a non-existent endpoint - // We'll do this by modifying the request to include a specific ID that doesn't exist - await expect( - sdk.mcp.deploy({ - spec: source, - name: 'Not Found Test', - // @ts-expect-error - intentionally passing a property that doesn't exist to trigger 404 - id: 'non-existent-id', - }) - ).rejects.toThrow(ApiError); - }); - - // Keep this test skipped as it's hard to reliably trigger a 500 error - it.skip('should throw ApiError for server errors (e.g., 500)', async () => { - // This test is skipped because it's difficult to reliably trigger a 500 error - // on the real backend without specific server conditions - }); - }); -});