Skip to content

refactor(FR-2529): extract backend.ai-client as standalone workspace package#6614

Merged
graphite-app[bot] merged 1 commit intomainfrom
refactor/FR-2529-extract-backend-ai-client
Apr 30, 2026
Merged

refactor(FR-2529): extract backend.ai-client as standalone workspace package#6614
graphite-app[bot] merged 1 commit intomainfrom
refactor/FR-2529-extract-backend-ai-client

Conversation

@yomybaby
Copy link
Copy Markdown
Member

@yomybaby yomybaby commented Apr 11, 2026

Resolves #6612(FR-2529)

Summary

  • Extract src/lib/backend.ai-client-esm.ts (6,015 lines) into packages/backend.ai-client/ as a standalone workspace package
  • Split monolithic file into 28 modular resource class files under src/resources/
  • Build with tsup: ESM output, .d.ts auto-generation, sourcemaps
  • Update all consumers: craco alias, global-stores import, jest mock, react-app-env.d.ts
  • Replace original file with thin re-export shim for backward compatibility
  • Follow backend.ai-ui patterns: naming (backend.ai-client), versioning (26.4.0-alpha.0), license (LGPL-3.0-or-later)

Verification

=== Relay: PASS ===
=== Lint: PASS ===
=== Format: PASS ===
=== TypeScript: PASS ===
=== ALL PASS ===

Package build: dist/index.js (174.5KB) + dist/index.d.ts (65.4KB)

Test plan

  • bash scripts/verify.sh → ALL PASS
  • pnpm build in packages/backend.ai-client/ succeeds
  • E2E smoke test: login form renders correctly (backend auth tests skipped — server unavailable in CI worktree)
  • Manual: verify pnpm run dev starts correctly and login works

🤖 Generated with Claude Code

@github-actions github-actions Bot added area:lib Library and SDK related issue. size:XL 500~ LoC labels Apr 11, 2026
Copy link
Copy Markdown
Member Author

yomybaby commented Apr 11, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment thread packages/backend.ai-client/src/client-config.ts
Comment thread packages/backend.ai-client/src/client.ts
Comment thread packages/backend.ai-client/src/client.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 11, 2026

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
8.97% (+0.01% 🔼)
1750/19515
🔴 Branches
8.07% (+0.01% 🔼)
1100/13626
🔴 Functions
5.42% (+0.01% 🔼)
288/5317
🔴 Lines
8.66% (+0.01% 🔼)
1641/18958

Test suite run success

854 tests passing in 39 suites.

Report generated by 🧪jest coverage report action from 30fe95d

@github-actions github-actions Bot added the type:enhance Add new features label Apr 11, 2026
@yomybaby yomybaby force-pushed the refactor/FR-2529-extract-backend-ai-client branch 3 times, most recently from 8137d0a to 30fe95d Compare April 11, 2026 09:02
@yomybaby yomybaby marked this pull request as ready for review April 11, 2026 10:01
Copilot AI review requested due to automatic review settings April 11, 2026 10:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Backend.AI API client out of the React app into a standalone workspace package (packages/backend.ai-client) and updates the React app/tooling to consume it via workspace dependency + webpack/TS aliases.

Changes:

  • Adds new backend.ai-client workspace package built with tsup (ESM, .d.ts, sourcemaps).
  • Splits client implementation into client.ts, client-config.ts, pep440.ts, types.ts, and modular resource wrappers under src/resources/.
  • Updates React app configuration (tsconfig paths, craco alias, Jest mapper, and imports) to use backend.ai-client.

Reviewed changes

Copilot reviewed 42 out of 46 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
react/tsconfig.json Adds TS path mapping for backend.ai-client to the workspace source entry.
react/src/react-app-env.d.ts Removes legacy module declaration for backend.ai-client-esm.
react/src/global-stores.ts Switches import from backend.ai-client-esm to backend.ai-client for global client wiring.
react/package.json Adds backend.ai-client as a workspace dependency.
react/jest.config.cjs Updates Jest module mapping to mock backend.ai-client.
react/craco.config.cjs Updates webpack aliasing and TS loader include paths for the new workspace package.
react/test/backendAiClient.mock.js Provides new Jest mock module for backend.ai-client.
pnpm-workspace.yaml Adds packages/backend.ai-client to the workspace.
packages/backend.ai-client/package.json Introduces new package metadata, exports, scripts, and deps for backend.ai-client.
packages/backend.ai-client/tsup.config.ts Defines tsup build configuration (ESM + d.ts + sourcemaps).
packages/backend.ai-client/tsconfig.json Adds TypeScript config for the new package.
packages/backend.ai-client/src/index.ts Exposes top-level exports and a backward-compatible backend namespace.
packages/backend.ai-client/src/client.ts Main client implementation migrated into the package.
packages/backend.ai-client/src/client-config.ts ClientConfig implementation migrated into the package.
packages/backend.ai-client/src/types.ts Defines exported SDK types used by the client/resources.
packages/backend.ai-client/src/pep440.ts PEP440 utilities used for version compatibility logic.
packages/backend.ai-client/src/pep440.test.ts Adds tests for PEP440 helpers (currently not wired to run).
packages/backend.ai-client/src/resources/index.ts Barrel export for resource wrappers.
packages/backend.ai-client/src/resources/agent.ts Agent API wrapper module.
packages/backend.ai-client/src/resources/cloud.ts Cloud API wrapper module.
packages/backend.ai-client/src/resources/compute-session.ts Compute session API wrapper module.
packages/backend.ai-client/src/resources/container-image.ts Container image API wrapper module.
packages/backend.ai-client/src/resources/domain.ts Domain API wrapper module.
packages/backend.ai-client/src/resources/edu-app.ts EduApp API wrapper module.
packages/backend.ai-client/src/resources/enterprise.ts Enterprise license API wrapper module.
packages/backend.ai-client/src/resources/group.ts Group API wrapper module.
packages/backend.ai-client/src/resources/keypair.ts Keypair API wrapper module.
packages/backend.ai-client/src/resources/maintenance.ts Maintenance API wrapper module.
packages/backend.ai-client/src/resources/model-service.ts Model service wrapper skeleton (TODO methods).
packages/backend.ai-client/src/resources/pipeline.ts Pipeline / PipelineJob / PipelineTaskInstance API wrappers.
packages/backend.ai-client/src/resources/registry.ts Registry config API wrapper module.
packages/backend.ai-client/src/resources/resource-policy.ts Resource policy API wrapper module.
packages/backend.ai-client/src/resources/resource-preset.ts Resource preset API wrapper module.
packages/backend.ai-client/src/resources/resources.ts Cluster resources aggregation helper.
packages/backend.ai-client/src/resources/scaling-group.ts Scaling group API wrapper module.
packages/backend.ai-client/src/resources/service.ts Service API wrapper module.
packages/backend.ai-client/src/resources/session-template.ts Session template API wrapper module.
packages/backend.ai-client/src/resources/setting.ts Settings API wrapper module.
packages/backend.ai-client/src/resources/storage-proxy.ts Storage proxy API wrapper module.
packages/backend.ai-client/src/resources/user.ts User API wrapper module.
packages/backend.ai-client/src/resources/user-config.ts User config (dotfiles/bootstrap script) API wrapper module.
packages/backend.ai-client/src/resources/utils.ts Misc SDK utility helpers.
packages/backend.ai-client/src/resources/vfolder.ts VFolder API wrapper module.
AGENTS.md Updates developer docs to reflect the new client package location/build.

Comment thread packages/backend.ai-client/src/resources/vfolder.ts
Comment thread packages/backend.ai-client/src/resources/vfolder.ts
Comment thread packages/backend.ai-client/src/resources/pipeline.ts
Comment thread packages/backend.ai-client/src/resources/user.ts
Comment thread packages/backend.ai-client/src/resources/keypair.ts
Comment thread packages/backend.ai-client/src/resources/user-config.ts
Comment thread packages/backend.ai-client/package.json
Comment thread packages/backend.ai-client/tsconfig.json
Comment thread packages/backend.ai-client/src/types.ts Outdated
Comment thread packages/backend.ai-client/src/client.ts
@yomybaby yomybaby requested a review from ironAiken2 April 30, 2026 04:39
@yomybaby yomybaby changed the base branch from main to graphite-base/6614 April 30, 2026 11:56
@yomybaby yomybaby force-pushed the refactor/FR-2529-extract-backend-ai-client branch from 30fe95d to a409bd8 Compare April 30, 2026 11:57
@yomybaby yomybaby changed the base branch from graphite-base/6614 to 04-30-fix_fr-2607_align_electron_publicpath_patch_with_vite_output April 30, 2026 11:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Coverage Report for root-coverage

Status Category Percentage Covered / Total
🔵 Lines 4.77% 28 / 586
🔵 Statements 5.14% 32 / 622
🔵 Functions 7.89% 6 / 76
🔵 Branches 4.98% 18 / 361
File CoverageNo changed files found.
Generated in workflow #121 for commit 7849a9a by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2026

Coverage Report for react-coverage (./react)

Status Category Percentage Covered / Total
🔵 Lines 6.88% 1781 / 25866
🔵 Statements 5.78% 1976 / 34138
🔵 Functions 5.34% 296 / 5539
🔵 Branches 4.11% 1291 / 31370
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
react/src/ambient.d.ts 100% 100% 100% 100%
react/src/global-stores.ts 73.54% 70.63% 73.91% 73.36% 87, 130, 181, 186-191, 212-225, 320-331, 341, 345-346, 369-400, 467-480
Generated in workflow #121 for commit 7849a9a by the Vitest Coverage Report Action

@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 30, 2026

Merge activity

…package (#6614)

Resolves #6612(FR-2529)

## Summary

- Extract `src/lib/backend.ai-client-esm.ts` (6,015 lines) into `packages/backend.ai-client/` as a standalone workspace package
- Split monolithic file into 28 modular resource class files under `src/resources/`
- Build with **tsup**: ESM output, `.d.ts` auto-generation, sourcemaps
- Update all consumers: craco alias, global-stores import, jest mock, react-app-env.d.ts
- Replace original file with thin re-export shim for backward compatibility
- Follow `backend.ai-ui` patterns: naming (`backend.ai-client`), versioning (`26.4.0-alpha.0`), license (`LGPL-3.0-or-later`)

## Verification

```
=== Relay: PASS ===
=== Lint: PASS ===
=== Format: PASS ===
=== TypeScript: PASS ===
=== ALL PASS ===
```

Package build: `dist/index.js` (174.5KB) + `dist/index.d.ts` (65.4KB)

## Test plan

- [x] `bash scripts/verify.sh` → ALL PASS
- [x] `pnpm build` in `packages/backend.ai-client/` succeeds
- [x] E2E smoke test: login form renders correctly (backend auth tests skipped — server unavailable in CI worktree)
- [ ] Manual: verify `pnpm run dev` starts correctly and login works

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:lib Library and SDK related issue. size:XL 500~ LoC type:enhance Add new features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: Extract backend.ai-client as a standalone workspace package

3 participants