@ossy/sdk
v1.40.3
Published
Software Development Kit for interacting with our services
Readme
@ossy/sdk
API client for Ossy services. Use with @ossy/sdk-react for React hooks.
Installation
npm install @ossy/sdk @ossy/sdk-reactQuick start
import { SDK } from '@ossy/sdk'
const sdk = SDK.of({
workspaceId: 'your-workspace-id',
apiUrl: 'https://api.ossy.se/api/v0', // optional, this is the default
})
// List resources in a folder
const resources = await sdk.resources.list({ location: '/docs' })
// Get a single resource
const resource = await sdk.resources.get({ id: 'resource-id' })Configuration
| Option | Description |
|--------|-------------|
| workspaceId | Your workspace identifier (required for most operations) |
| apiUrl | API base URL (default: https://api.ossy.se/api/v0) |
| authorization | Bearer token for authenticated requests |
API overview
Workspaces
sdk.workspaces.current()— Get current workspacesdk.workspaces.list()— List workspacessdk.workspaces.get({ workspaceId })— Get workspace by IDsdk.workspaces.create(payload)— Create workspacesdk.workspaces.importSchemas(...)— Import schemassdk.workspaces.getSchemas(...)— Get schemas
Resources
sdk.resources.list({ location })— List resources in foldersdk.resources.get({ id })— Get resource by IDsdk.resources.create(payload)— Create resourcesdk.resources.search(query)— Search resourcessdk.resources.remove({ id })— Delete resourcesdk.resources.updateContent(...)— Update resource contentsdk.resources.move(...)— Move resourcesdk.resources.rename(...)— Rename resourcesdk.resources.upload({ location, file })— Upload file
Auth
sdk.auth.signIn(payload)— Sign insdk.auth.signOff()— Sign offsdk.auth.getAuthenticatedUser()— Get current user
Current user
sdk.currentUser.get()— Get current usersdk.currentUser.update(payload)— Update usersdk.currentUser.history()— Get user history
With React
Use @ossy/sdk-react for WorkspaceProvider and useSdk(). Domain hooks (useResources, useAuthentication, …) live in feature packages — see @ossy/sdk-react README.
import { ReactSdk, WorkspaceProvider } from '@ossy/sdk-react'
import { AuthenticationProvider } from '@ossy/authentication'
const sdk = ReactSdk.of({ workspaceId: 'your-workspace-id' })
export const App = () => (
<WorkspaceProvider sdk={sdk}>
<AuthenticationProvider>
<YourApp />
</AuthenticationProvider>
</WorkspaceProvider>
)Agents (MCP)
MCP is embedded in the app server — same actions as sdk.invoke, exposed as tools from build/capabilities.json.
{
"mcpServers": {
"ossy-local": {
"url": "http://localhost:3006/mcp",
"headers": {
"Authorization": "Bearer your-jwt-token",
"workspaceId": "your-workspace-id"
}
}
}
}See TODO-AGENT-MCP.md.
Invoking platform actions
Writes and commands use sdk.invoke(action, payload) with a platform action POJO or id string:
import { SDK } from '@ossy/sdk'
import { BookingCreate } from '@ossy/booking'
const sdk = SDK.of({ workspaceId: 'your-workspace-id' })
// POJO (preferred) — importable on client and server
await sdk.invoke(BookingCreate, { providerId, startAt, duration })
// HTTP: POST /actions with { action: '@ossy/booking/actions/create', payload: { … } }Reads use location paths — not invoke:
await sdk.resources.list({ location: '/@ossy/booking/services/' })Push invalidation (ADR 0008)
Subscribe to workspace SSE events at GET /events to invalidate client read caches when server state changes.
import { SDK } from '@ossy/sdk'
const sdk = SDK.of({ workspaceId: 'your-workspace-id' })
const unsubscribe = sdk.subscribePush({
onMessage: (message) => {
// message.invalidate — cache keys to drop (when present)
console.log(message.kind, message.invalidate)
},
onError: (error) => {
console.error('SSE error', error)
},
})
// later
unsubscribe()PushMessage fields include kind, type, resourceId, event, version, eventId, scope.workspaceId, and invalidate (string array of cache keys).
Requires workspaceId on the SDK config, or a workspace cookie on the same origin. Returns a no-op unsubscribe when EventSource is unavailable (SSR/tests).
With React, WorkspaceProvider from @ossy/sdk-react wires this automatically via usePushInvalidation.
