-
Notifications
You must be signed in to change notification settings - Fork 1
CLI: Add remote API commands for Data API and Metadata API #1059
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
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4a2756a
Initial plan
Claude 4a4652b
Add P0 remote API commands for auth, data, and metadata
Claude 978289b
Add documentation for remote API commands
Claude aefd8d6
Add unit tests for remote API commands and utilities
Claude b1b8cc9
Fix CI: remove unused imports, fix URL injection, and update pnpm-loc…
Copilot b967add
Address all PR review feedback: client URL fallback, token exposure, …
Copilot bfda7e0
Fix Ctrl+C cleanup in login.ts and static import in data/delete.ts
Copilot 820ae34
Fix TS2345: add required type: 'email' to client.auth.login() call in…
Copilot 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,197 @@ | ||
| # Remote API Commands | ||
|
|
||
| The ObjectStack CLI now includes commands to interact with a running ObjectStack server via its REST APIs. | ||
|
|
||
| ## Authentication | ||
|
|
||
| Before using remote API commands, you need to authenticate: | ||
|
|
||
| ```bash | ||
| # Login and store credentials | ||
| os auth login --url https://api.example.com | ||
|
|
||
| # Show current session | ||
| os auth whoami | ||
|
|
||
| # Logout (clear stored credentials) | ||
| os auth logout | ||
| ``` | ||
|
|
||
| Credentials are stored in `~/.objectstack/credentials.json` and automatically used for subsequent commands. | ||
|
|
||
| Alternatively, you can provide credentials via environment variables or flags: | ||
|
|
||
| ```bash | ||
| # Using environment variables | ||
| export OBJECTSTACK_URL=https://api.example.com | ||
| export OBJECTSTACK_TOKEN=your-token-here | ||
|
|
||
| # Using flags | ||
| os data query project_task --url https://api.example.com --token your-token-here | ||
| ``` | ||
|
|
||
| ## Data API Commands | ||
|
|
||
| ### Query Records | ||
|
|
||
| ```bash | ||
| # Query all records | ||
| os data query project_task | ||
|
|
||
| # Filter records | ||
| os data query project_task --filter '{"status":"open"}' | ||
|
|
||
| # Limit and pagination | ||
| os data query project_task --limit 10 --offset 0 | ||
|
|
||
| # Select specific fields | ||
| os data query project_task --fields name,status,created_at | ||
|
|
||
| # Sort results | ||
| os data query project_task --sort -created_at # descending | ||
| os data query project_task --sort created_at # ascending | ||
|
|
||
| # Output formats | ||
| os data query project_task --format json | ||
| os data query project_task --format yaml | ||
| os data query project_task --format table # default | ||
| ``` | ||
|
|
||
| ### Get a Single Record | ||
|
|
||
| ```bash | ||
| os data get project_task abc123 | ||
| os data get project_task abc123 --format json | ||
| ``` | ||
|
|
||
| ### Create a Record | ||
|
|
||
| ```bash | ||
| # From JSON string | ||
| os data create project_task '{"name":"New Task","status":"open"}' | ||
|
|
||
| # From JSON file | ||
| os data create project_task --data task.json | ||
| ``` | ||
|
|
||
| ### Update a Record | ||
|
|
||
| ```bash | ||
| # From JSON string | ||
| os data update project_task abc123 '{"status":"completed"}' | ||
|
|
||
| # From JSON file | ||
| os data update project_task abc123 --data update.json | ||
| ``` | ||
|
|
||
| ### Delete a Record | ||
|
|
||
| ```bash | ||
| os data delete project_task abc123 | ||
| ``` | ||
|
|
||
| ## Metadata API Commands | ||
|
|
||
| ### List Metadata Types | ||
|
|
||
| ```bash | ||
| # List all available metadata types | ||
| os meta list | ||
|
|
||
| # List items of a specific type | ||
| os meta list object | ||
| os meta list plugin | ||
| os meta list view | ||
| ``` | ||
|
|
||
| ### Get Metadata Item | ||
|
|
||
| ```bash | ||
| os meta get object project_task | ||
| os meta get plugin my-plugin --format json | ||
| ``` | ||
|
|
||
| ### Register Metadata | ||
|
|
||
| ```bash | ||
| # Register from JSON file | ||
| os meta register object --data object-definition.json | ||
| os meta register plugin --data plugin-manifest.json | ||
| ``` | ||
|
|
||
| The metadata file must include a `name` field: | ||
|
|
||
| ```json | ||
| { | ||
| "name": "my_custom_object", | ||
| "label": "My Custom Object", | ||
| "fields": { | ||
| "name": { | ||
| "type": "text", | ||
| "label": "Name" | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Delete Metadata | ||
|
|
||
| ```bash | ||
| os meta delete object my_custom_object | ||
| os meta delete plugin my-plugin | ||
| ``` | ||
|
|
||
| ## Output Formats | ||
|
|
||
| Most commands support multiple output formats via the `--format` flag: | ||
|
|
||
| - `json` - Machine-readable JSON output | ||
| - `yaml` - Human-readable YAML output | ||
| - `table` - Formatted table output (default for most commands) | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| The following environment variables are supported: | ||
|
|
||
| - `OBJECTSTACK_URL` - Default server URL (default: `http://localhost:3000`) | ||
| - `OBJECTSTACK_TOKEN` - Authentication token (alternative to `os auth login`) | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Complete Workflow | ||
|
|
||
| ```bash | ||
| # 1. Login | ||
| os auth login --url https://api.example.com | ||
| Email: user@example.com | ||
| Password: ******** | ||
|
|
||
| # 2. Query data | ||
| os data query project_task --filter '{"status":"open"}' --limit 5 | ||
|
|
||
| # 3. Create a new record | ||
| os data create project_task '{"name":"Implement feature","status":"open","priority":"high"}' | ||
|
|
||
| # 4. Update the record | ||
| os data update project_task abc123 '{"status":"in_progress"}' | ||
|
|
||
| # 5. List metadata | ||
| os meta list object | ||
|
|
||
| # 6. Get object definition | ||
| os meta get object project_task --format yaml | ||
| ``` | ||
|
|
||
| ### CI/CD Integration | ||
|
|
||
| ```bash | ||
| # Use token authentication in CI/CD pipelines | ||
| export OBJECTSTACK_URL=https://api.production.com | ||
| export OBJECTSTACK_TOKEN=${{ secrets.OBJECTSTACK_TOKEN }} | ||
|
|
||
| # Deploy metadata | ||
| os meta register object --data objects/project_task.json | ||
|
|
||
| # Verify deployment | ||
| os meta get object project_task --format json | ||
| ``` |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The CHANGELOG claims multiple output formats
--format json|table|yaml, but several new commands only allowjson|table(e.g., data delete, meta register, meta delete). Either expand those commands to supportyamlor adjust this entry to reflect the actual supported formats to avoid misleading users.