@newgameplusinc/organization-sdk
v1.0.0
Published
Official JavaScript/TypeScript SDK for the Odyssey Organization Service.
Keywords
Readme
Odyssey Organization SDK
Official JavaScript/TypeScript SDK for the Odyssey Organization Service.
This SDK provides a typed, consistent, and runtime-safe interface to interact with the Odyssey Organization REST API, including organizations, organization users, spaces, rooms, invites, and related resources.
Requirements
- Node.js 18+
- Valid API key for the Odyssey Organization Service
Installation
npm install @newgameplusinc/organization-sdkInitialization
import { OdysseyOrgSDK } from "@newgameplusinc/organization-sdk";
const sdk = new OdysseyOrgSDK({
apiKey: "YOUR_API_KEY",
});The API key is sent as a Bearer token in the Authorization header.
Usage
Organizations
Create an organization:
await sdk.organizations.create({
name: "Acme Inc",
});Update an organization:
await sdk.organizations.update("org_id", {
name: "New Organization Name",
});Get organization by ID:
const org = await sdk.organizations.getOrgById("org_id");Get organizations of current user:
const orgs = await sdk.organizations.getUserOrgs();Delete organization:
await sdk.organizations.deleteOrg("org_id");Organization Users
Update organization user:
await sdk.organizations.updateOrgUser("org_user_id", {
roleId: "admin",
});Get organization user:
const users = await sdk.organizations.getOrgUser("org_id");Delete organization user:
await sdk.organizations.deleteOrgUser("org_user_id");Organization Invitations
Create org user invitation:
await sdk.organizationInvite.create({
orgId: "org_id",
email: "[email protected]",
roleId: "member",
});Accept invitation:
await sdk.organizationInvite.accept("invite_id");Reject invitation:
await sdk.organizationInvite.reject("invite_id");Spaces
Create space:
await sdk.space.create({
orgId: "org_id",
name: "Design Space",
spaceTemplateId: "template_id",
unrealProject: {
unrealProjectId: "project_id",
unrealProjectVersionId: "version_id",
},
});Update space:
await sdk.space.update("space_id", {
name: "Updated Space Name",
});Get spaces by organization:
const spaces = await sdk.space.getSpaceByOrg("org_id");Get spaces by project:
const spaces = await sdk.space.getSpaceByProject("project_id");Delete space:
await sdk.space.delete("space_id");Space Users
Get space users:
const users = await sdk.space.getSpaceUser("space_id");Update space user:
await sdk.space.updateSpaceUser("space_user_id", {
roleId: "viewer",
});Delete space user:
await sdk.space.deleteSpaceUser("space_user_id");Space Settings
Update space settings:
await sdk.space.updateSetting("space_id", {
isPublic: true,
enableSharding: true,
});Space Invitations
Create space invite:
await sdk.spaceInvite.create({
spaceId: "space_id",
email: "[email protected]",
roleId: "viewer",
});Accept space invite:
await sdk.spaceInvite.accept("invite_id");Reject space invite:
await sdk.spaceInvite.reject("invite_id");Error Handling
All errors are normalized and thrown as ApiError.
import { ApiError } from "@odyssey/organization-sdk";
try {
await sdk.organizations.update("org_id", { name: "" });
} catch (err) {
if (err instanceof ApiError) {
console.error(err.status);
console.error(err.message);
console.error(err.code);
console.error(err.details);
}
}All network, validation, and authorization errors follow the same error format.
Design Notes
- Thin wrapper over the REST API
- Prisma models define response types
- Validation schemas define input types
- Runtime argument checks for JavaScript users
- Full type safety for TypeScript users
Build
npm run buildLicense
MIT
