generated from finos-labs/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 98
Copy calm server to a separate package calm-server.
#2167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rocketstack-matt
merged 22 commits into
finos:main
from
markscott-ms:issues/2051-calm-server
Feb 28, 2026
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
08304c9
feat(calm-server): add initial files for calm-server
markscott-ms bb14d87
feat(calm-server): copy server functionality into calm-server
markscott-ms 63903ba
feat(calm-server): bundle schema into calm-server
markscott-ms 5fdab6c
feat(calm-server): add tests
markscott-ms 39a9951
feat(calm-server): listen on 127.0.0.1 by default, with --host option
markscott-ms 4b1ca5b
feat(calm-server): rate limiting options rather than hardcoded
markscott-ms e9df2d8
feat(calm-server): remove cli config - expect options on the command …
markscott-ms bb70238
feat(calm-server): update README and AGENTS.md
markscott-ms 802adef
feat(ci): add calm-server build workflow
markscott-ms 6531027
chore(calm-server): update PR template to include missing modules
markscott-ms 8b7a18f
chore(calm-server): fix lint issues
markscott-ms 5d0cc41
feat(calm-server): address review comments
markscott-ms 49a698f
chore(ci): add calm-server as a valid scope for commitlint
markscott-ms e72edcb
fix(calm-server): suppress unused var in tests
markscott-ms 0bfe35b
feat(calm-server): improve test coverage, remove CLI references
markscott-ms aca06df
Merge branch 'main' into issues/2051-calm-server
markscott-ms f016f1b
feat(calm-server): add CODEOWNERS, avoid deep fragile linking
markscott-ms 48bd001
feat(calm-server): update README
markscott-ms 40287aa
Merge branch 'main' into issues/2051-calm-server
markscott-ms 1ae9ffa
feat(calm-server): only import exported functions and types from shared
markscott-ms e82ecb1
Merge branch 'issues/2051-calm-server' of https://github.com/markscot…
markscott-ms bd0bb1b
Merge branch 'main' into issues/2051-calm-server
markscott-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| name: Build CALM Server | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - 'main' | ||
| - 'release*' | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| - 'release*' | ||
|
|
||
| jobs: | ||
| calm-server: | ||
| name: Build, Test, and Lint CALM Server Module | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout PR Branch | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | ||
| with: | ||
| node-version: v22 | ||
|
|
||
| - name: Install workspace | ||
| run: npm ci | ||
|
|
||
| - name: Lint CALM Server Module | ||
| run: npm run lint --workspace=calm-server | ||
|
|
||
| - name: Build workspace | ||
| run: npm run build:calm-server | ||
|
|
||
| - name: Run tests with coverage for CALM Server | ||
| run: npm run test:calm-server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| # @finos/calm-server | ||
|
|
||
| The `calm-server` executable provides a standalone HTTP server implementation of CALM validation functionality. | ||
|
|
||
| ## Architecture | ||
|
|
||
| The calm-server provides: | ||
|
|
||
| - **Bundled CALM Schemas** - All CALM schemas (release and draft) are bundled during build | ||
| - **Health Check Endpoint** (`/health`) - Status endpoint for monitoring | ||
| - **Validation Endpoint** (`/calm/validate`) - POST endpoint for validating CALM architectures | ||
| - **Rate Limiting** - Protects against abuse with 100 requests per 15 minutes per IP | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| calm-server/ | ||
| ├── src/ | ||
| │ ├── index.ts # Entry point, CLI argument parsing | ||
| │ ├── server/ | ||
| │ │ ├── cli-server.ts # Express server startup | ||
| │ │ └── routes/ | ||
| │ │ ├── routes.ts # Router setup | ||
| │ │ ├── health-route.ts # Health check endpoint | ||
| │ │ └── validation-route.ts # Architecture validation endpoint | ||
| │ └── *.spec.ts # Unit tests | ||
| ├── dist/ | ||
| │ ├── index.js # Compiled executable | ||
| │ └── calm/ # Bundled CALM schemas | ||
| │ ├── release/ # Released schema versions | ||
| │ └── draft/ # Draft schema versions | ||
| ├── package.json | ||
| ├── tsconfig.json | ||
| ├── tsconfig.build.json | ||
| ├── tsup.config.ts # Build configuration | ||
| ├── vitest.config.ts # Test configuration | ||
| └── eslint.config.mjs # Linting configuration | ||
| ``` | ||
|
|
||
| ## Building & Running | ||
|
|
||
| ### Build the package | ||
| ```bash | ||
| npm run build:calm-server | ||
| ``` | ||
|
|
||
| This builds the TypeScript code and copies all CALM schemas from `calm/release` and `calm/draft` into `dist/calm/`. | ||
|
|
||
| ### Run the server locally | ||
| ```bash | ||
| # Using bundled schemas (default) | ||
| ./calm-server/dist/index.js --port 3000 --verbose | ||
|
|
||
| # Or with custom schemas | ||
| ./calm-server/dist/index.js -s ../calm/release --port 3000 --verbose | ||
|
|
||
| # Or using npm | ||
| npm run build:calm-server | ||
| node calm-server/dist/index.js --port 3000 | ||
| ``` | ||
|
|
||
| ### Global installation (for development) | ||
| ```bash | ||
| npm run link:calm-server | ||
|
|
||
| # Use bundled schemas (default) | ||
| calm-server --port 3000 | ||
|
|
||
| # Or provide custom schemas | ||
| calm-server -s /path/to/schemas --port 3000 | ||
| ``` | ||
|
|
||
| ## Command-Line Options | ||
|
|
||
| ``` | ||
| Usage: calm-server [options] | ||
|
|
||
| CALM Server - A server implementation for the Common Architecture Language Model | ||
|
|
||
| Options: | ||
| -V, --version output the version number | ||
| --port <port> Port to run the server on (default: "3000") | ||
| --host <host> Host to bind the server to (default: "127.0.0.1") | ||
| -s, --schema-directory <path> Path to the directory containing the meta schemas to use. | ||
| (default: bundled schemas in dist/calm) | ||
| -v, --verbose Enable verbose logging (default: false) | ||
| -c, --calm-hub-url <url> URL to CALMHub instance | ||
| --rate-limit-window <ms> Rate limit window in milliseconds (default: 900000 = 15 minutes) | ||
| --rate-limit-max <requests> Max requests per IP within the rate limit window (default: 100) | ||
| -h, --help display help for command | ||
| ``` | ||
|
|
||
| ### Security Notes | ||
|
|
||
| - **Default Host**: The server binds to `127.0.0.1` (localhost) by default | ||
| - **No Authentication**: The server has **NO authentication or authorization controls** | ||
| - **Network Exposure Warning**: If you bind to a non-localhost host (e.g., `0.0.0.0`, `::`, public IP), a warning will be logged. Only do this in trusted network environments | ||
|
|
||
| ## Testing | ||
|
|
||
| ### Run tests | ||
| ```bash | ||
| npm run test:calm-server | ||
| ``` | ||
|
|
||
| ### Test the health endpoint | ||
| ```bash | ||
| # Start the server (uses bundled schemas) | ||
| node calm-server/dist/index.js & | ||
| SERVER_PID=$! | ||
|
|
||
| # Test health | ||
| curl http://localhost:3000/health | ||
|
|
||
| # Clean up | ||
| kill $SERVER_PID | ||
| ``` | ||
|
|
||
| ### Test the validation endpoint | ||
| ```bash | ||
| # With a CALM architecture JSON | ||
| curl -X POST http://localhost:3000/calm/validate \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{"architecture": "{\"$schema\": \"https://...\"...}"}' | ||
| ``` | ||
|
|
||
| ## Dependencies | ||
|
|
||
| - `@finos/calm-shared` - Shared utilities, validation logic, schema handling | ||
| - `express` - HTTP server framework | ||
| - `express-rate-limit` - Rate limiting middleware | ||
| - `commander` - CLI argument parsing | ||
|
|
||
| ## Development Notes | ||
|
|
||
| ### Copying from CLI | ||
|
|
||
| The calm-server implementation mirrors the server functionality from the CLI package (`cli/src/server/`): | ||
|
|
||
| - `src/server/cli-server.ts` - Express server setup | ||
| - `src/server/routes/routes.ts` - Route configuration | ||
| - `src/server/routes/health-route.ts` - Health check | ||
| - `src/server/routes/validation-route.ts` - Architecture validation | ||
|
|
||
| Both implementations share the same core logic for validation and schema handling through the `@finos/calm-shared` package. | ||
|
|
||
| ### Build Configuration | ||
|
|
||
| The tsup configuration: | ||
| - Bundles shared packages (`@finos/calm-shared`, `@finos/calm-models`, `@finos/calm-widgets`) | ||
| - Adds Node.js shebang via banner for executable | ||
| - Outputs CommonJS format with tree-shaking enabled | ||
| - Marks external `node_modules` as external (not bundled) | ||
|
|
||
| ## Linking for Development | ||
|
|
||
| After building, you can link the executable globally: | ||
|
|
||
| ```bash | ||
| npm run link:calm-server | ||
| calm-server --help | ||
| ``` | ||
|
|
||
| This allows testing the executable without needing to build or reference the dist directory. | ||
|
|
||
| ## License | ||
|
|
||
| Apache-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # @finos/calm-server | ||
|
|
||
| A standalone HTTP server for the Common Architecture Language Model (CALM) validation functionality. | ||
|
|
||
| The `calm-server` executable provides HTTP endpoints for CALM architecture validation. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Bundled CALM Schemas** - All CALM schemas (release and draft) are bundled with the executable | ||
| - **Health Check Endpoint** (`GET /health`) - Status endpoint for monitoring | ||
| - **Validation Endpoint** (`POST /calm/validate`) - Validate CALM architectures against schemas | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Starting the Server | ||
|
|
||
| ```bash | ||
| # Basic usage (uses bundled schemas by default) | ||
| calm-server | ||
|
|
||
| # With custom port | ||
| calm-server --port 8080 | ||
|
|
||
| # With verbose logging | ||
| calm-server --port 3000 --verbose | ||
|
|
||
| # Or provide a custom schema directory | ||
| calm-server -s /path/to/calm/schemas --port 3000 | ||
| ``` | ||
|
|
||
| ### Command-Line Options | ||
|
|
||
| ``` | ||
| Usage: calm-server [options] | ||
|
|
||
| Options: | ||
| -V, --version output the version number | ||
| --port <port> Port to run the server on (default: "3000") | ||
| --host <host> Host to bind the server to (default: "127.0.0.1") | ||
| -s, --schema-directory <path> Path to the directory containing the meta schemas | ||
| (default: bundled schemas in dist/calm) | ||
| -v, --verbose Enable verbose logging (default: false) | ||
| -c, --calm-hub-url <url> URL to CALMHub instance | ||
| --rate-limit-window <ms> Rate limit window in milliseconds (default: 900000 = 15 minutes) | ||
| --rate-limit-max <requests> Max requests per IP within the rate limit window (default: 100) | ||
| -h, --help display help for command | ||
| ``` | ||
|
|
||
| ### Security Considerations | ||
|
|
||
| - **Default Host is Localhost**: By default, the server binds to `127.0.0.1` for security | ||
| - **No Built-in Authentication**: This server has no authentication or authorization controls | ||
| - **Network Exposure**: When binding to non-localhost addresses, a security warning is logged. Only expose to the network in trusted environments | ||
|
|
||
| ## API Endpoints | ||
|
|
||
| ### Health Check | ||
|
|
||
| Check if the server is running: | ||
|
|
||
| ```bash | ||
| curl http://localhost:3000/health | ||
| ``` | ||
|
|
||
| Response: | ||
| ```json | ||
| { | ||
| "status": "OK" | ||
| } | ||
| ``` | ||
|
|
||
| ### Validate Architecture | ||
|
|
||
| Validate a CALM architecture document: | ||
|
|
||
| ```bash | ||
| curl -X POST http://localhost:3000/calm/validate \ | ||
| -H "Content-Type: application/json" \ | ||
| -d '{ | ||
| "architecture": "{\"$schema\":\"https://calm.finos.org/release/1.2/meta/calm.json\",\"nodes\":[]}" | ||
| }' | ||
| ``` | ||
|
|
||
| Response (success): | ||
| ```json | ||
| { | ||
| "jsonSchemaValidationOutputs":[], | ||
| "spectralSchemaValidationOutputs":[], | ||
| "hasErrors":false, | ||
| "hasWarnings":false | ||
| } | ||
| ``` | ||
|
|
||
| Response (validation errors): | ||
| ```json | ||
| { | ||
| "jsonSchemaValidationOutputs":[], | ||
| "spectralSchemaValidationOutputs":[...], | ||
| "hasErrors":true, | ||
| "hasWarnings":false | ||
| } | ||
| ``` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Building | ||
|
|
||
| ```bash | ||
| # From repository root | ||
| npm run build:calm-server | ||
|
|
||
| # Or from calm-server directory | ||
| cd calm-server | ||
| npm run build | ||
| ``` | ||
|
|
||
| ### Testing | ||
|
|
||
| ```bash | ||
| # From repository root | ||
| npm run test:calm-server | ||
|
|
||
| # Or from calm-server directory | ||
| cd calm-server | ||
| npm test | ||
|
|
||
| # With coverage | ||
| npm test -- --coverage | ||
| ``` | ||
|
|
||
| ### Linting | ||
|
|
||
| ```bash | ||
| # From calm-server directory | ||
| npm run lint | ||
| npm run lint-fix | ||
| ``` | ||
|
|
||
| ## License | ||
|
|
||
| Apache-2.0 | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.