Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f8dc885

Browse files
authored
Merge branch 'main' into issue/325-literal-value-zero
2 parents 3e50216 + 389cf69 commit f8dc885

File tree

12 files changed

+1487
-7
lines changed

12 files changed

+1487
-7
lines changed

‎REMOTE_OPERATIONS.md‎

Lines changed: 422 additions & 0 deletions
Large diffs are not rendered by default.

‎REMOTE_OPERATIONS_IMPLEMENTATION.md‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Remote Operations Implementation Details
2+
3+
## Summary
4+
5+
Native remote operations support has been implemented in the TerminusDB JavaScript client based on the OpenAPI specification from the CleoDB repository.
6+
7+
## Implementation
8+
9+
### API Endpoints (from OpenAPI spec)
10+
11+
Based on `/Users/hoijnet/Code/terminusdb/cleodb/docs/openapi.yaml`:
12+
13+
**POST `/remote/{path}`** - Create a new remote
14+
- Path parameter: `branch_path` (e.g., `admin/test/local/branch/foo`)
15+
- Request body:
16+
```json
17+
{
18+
"remote_name": "origin",
19+
"remote_location": "http://cloud.terminusdb.com/org/db"
20+
}
21+
```
22+
- Response: `{ "@type": "api:RemoteResponse", "api:status": "api:success" }`
23+
24+
**GET `/remote/{path}?remote_name=origin`** - Get remote details
25+
- Path parameter: `branch_path`
26+
- Query parameter: `remote_name`
27+
- Response:
28+
```json
29+
{
30+
"@type": "api:RemoteResponse",
31+
"api:remote_name": "origin",
32+
"api:remote_url": "http://cloud.terminusdb.com/org/db",
33+
"api:status": "api:success"
34+
}
35+
```
36+
37+
**PUT `/remote/{path}`** - Update a remote
38+
- Path parameter: `branch_path`
39+
- Request body:
40+
```json
41+
{
42+
"remote_name": "origin",
43+
"remote_location": "http://new-cloud.terminusdb.com/org/db"
44+
}
45+
```
46+
- Response: `{ "@type": "api:RemoteResponse", "api:status": "api:success" }`
47+
48+
**DELETE `/remote/{path}?remote_name=origin`** - Delete a remote
49+
- Path parameter: `branch_path`
50+
- Query parameter: `remote_name`
51+
- Response: `{ "@type": "api:RemoteResponse", "api:status": "api:success" }`
52+
53+
### Client Methods
54+
55+
```javascript
56+
// ConnectionConfig - URL generation
57+
ConnectionConfig.prototype.remoteURL()
58+
// Returns: http://server/api/remote/org/db/local/branch/main
59+
60+
// WOQLClient - CRUD operations
61+
WOQLClient.prototype.createRemote(remoteName, remoteLocation)
62+
WOQLClient.prototype.getRemote(remoteName)
63+
WOQLClient.prototype.updateRemote(remoteName, remoteLocation)
64+
WOQLClient.prototype.deleteRemote(remoteName)
65+
```
66+
67+
### Key Design Decisions
68+
69+
1. **URL Structure**: Uses `branchBase('remote')` to include the full branch path as required by the API
70+
2. **Payload Format**: POST/PUT send `{ remote_name, remote_location }` in body
71+
3. **Query Parameters**: GET/DELETE use `?remote_name=` query parameter
72+
4. **Error Handling**: All methods validate parameters before making API calls
73+
74+
## Testing
75+
76+
### Unit Tests (`test/remoteOperations.spec.js`)
77+
- 28 tests covering all CRUD operations
78+
- Parameter validation
79+
- URL generation
80+
- Mock API responses
81+
- ✅ All passing
82+
83+
### Integration Tests (`integration_tests/remote_operations.test.ts`)
84+
- 29 tests for real server interaction
85+
- Complete CRUD workflows
86+
- Multiple remotes
87+
- Special characters handling
88+
- Error scenarios
89+
90+
**Note**: Integration tests require a TerminusDB server with full remote API support. Some tests may fail on older server versions that don't fully implement the `/api/remote/` endpoint.
91+
92+
## Server Compatibility
93+
94+
The remote API was added in TerminusDB/CleoDB and may not be available in all versions. To check if your server supports remotes:
95+
96+
```javascript
97+
try {
98+
await client.createRemote('test', 'http://example.com/org/db');
99+
console.log('Remote API supported');
100+
} catch (error) {
101+
if (error.message.includes('Bad descriptor path')) {
102+
console.log('Server does not fully support remote API yet');
103+
}
104+
}
105+
```
106+
107+
## OpenAPI Reference
108+
109+
Full API specification: `/Users/hoijnet/Code/terminusdb/cleodb/docs/openapi.yaml`
110+
Lines 864-1013 contain the remote endpoint definitions.
111+
112+
## Files Modified
113+
114+
- `lib/connectionConfig.js` - Added `remoteURL()` method
115+
- `lib/const.js` - Added remote operation constants
116+
- `lib/woqlClient.js` - Added 4 CRUD methods
117+
- `test/remoteOperations.spec.js` - 28 unit tests
118+
- `integration_tests/remote_operations.test.ts` - 29 integration tests
119+
- `REMOTE_OPERATIONS.md` - User-facing documentation

‎docs/api/typedef.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ the DELETE document interface query parameters
9595
| Name | Type | Description |
9696
| --- | --- | --- |
9797
| type | <code>&#x27;basic&#x27;</code> \| <code>&#x27;jwt&#x27;</code> \| <code>&#x27;apikey&#x27;</code> | the authorization type of an TerminusDB connection |
98-
| [user] | <code>string</code> \| <code>boolean</code> | the user id | I don't need the user with the jwt token |
98+
| [user] | <code>string</code> \| <code>boolean</code> | the user id |
9999
| key | <code>string</code> | the connection key |
100100

101101

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /