@newgameplusinc/odyssey-organization-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1030 -0
- package/dist/index.js +65 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +75 -75
package/README.md
CHANGED
|
@@ -0,0 +1,1030 @@
|
|
|
1
|
+
# @newgameplusinc/odyssey-organization-sdk
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@newgameplusinc/odyssey-organization-sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/@newgameplusinc/odyssey-organization-sdk)
|
|
5
|
+
|
|
6
|
+
Official TypeScript SDK for the Odyssey Organization backend. Provides a fully typed, modular HTTP client for health checks, organizations, invites, projects, spaces, and space invites.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Table of Contents
|
|
11
|
+
|
|
12
|
+
- [Installation](#installation)
|
|
13
|
+
- [Quick Start](#quick-start)
|
|
14
|
+
- [Architecture](#architecture)
|
|
15
|
+
- [Configuration](#configuration)
|
|
16
|
+
- [Error Handling](#error-handling)
|
|
17
|
+
- [Debug Logging](#debug-logging)
|
|
18
|
+
- [API Reference](#api-reference)
|
|
19
|
+
- [Health](#health)
|
|
20
|
+
- [Organizations](#organizations)
|
|
21
|
+
- [Organization Invites](#organization-invites)
|
|
22
|
+
- [Projects](#projects)
|
|
23
|
+
- [Spaces](#spaces)
|
|
24
|
+
- [Space Invites](#space-invites)
|
|
25
|
+
- [Types Reference](#types-reference)
|
|
26
|
+
- [Config](#config)
|
|
27
|
+
- [Common](#common)
|
|
28
|
+
- [Organization Types](#organization-types)
|
|
29
|
+
- [Project Types](#project-types)
|
|
30
|
+
- [Space Types](#space-types)
|
|
31
|
+
- [Health Types](#health-types)
|
|
32
|
+
- [Error Types](#error-types)
|
|
33
|
+
- [Versioning](#versioning)
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install @newgameplusinc/odyssey-organization-sdk
|
|
41
|
+
# or
|
|
42
|
+
yarn add @newgameplusinc/odyssey-organization-sdk
|
|
43
|
+
# or
|
|
44
|
+
pnpm add @newgameplusinc/odyssey-organization-sdk
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createOrganizationSDK } from "@newgameplusinc/odyssey-organization-sdk";
|
|
53
|
+
|
|
54
|
+
const sdk = createOrganizationSDK({ apiKey: "your-api-key" });
|
|
55
|
+
|
|
56
|
+
const health = await sdk.health.getHealth();
|
|
57
|
+
console.log(health.status);
|
|
58
|
+
|
|
59
|
+
const organization = await sdk.organization.create({
|
|
60
|
+
name: "New Game Plus",
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const projects = await sdk.projects.getByOrg(organization.id, {
|
|
64
|
+
page: 1,
|
|
65
|
+
limit: 10,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const space = await sdk.spaces.create({
|
|
69
|
+
orgId: organization.id,
|
|
70
|
+
name: "Main Lobby",
|
|
71
|
+
spaceTemplateId: "template-id",
|
|
72
|
+
unrealProject: {
|
|
73
|
+
unrealProjectId: "uproject-id",
|
|
74
|
+
unrealProjectVersionId: "uproject-version-id",
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can also use the namespace default export:
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import OrganizationSDK from "@newgameplusinc/odyssey-organization-sdk";
|
|
83
|
+
|
|
84
|
+
const sdk = OrganizationSDK.create({ apiKey: "your-api-key" });
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Architecture
|
|
90
|
+
|
|
91
|
+
The SDK is structured as a set of focused modules. Each module handles one domain of the backend API, and all modules share a single configured HTTP client created once at initialization.
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
createOrganizationSDK({ apiKey })
|
|
95
|
+
│
|
|
96
|
+
├── sdk.health → /health
|
|
97
|
+
├── sdk.organization → /organizations
|
|
98
|
+
├── sdk.organizationInvites → /organizations-invite
|
|
99
|
+
├── sdk.projects → /projects
|
|
100
|
+
├── sdk.spaces → /spaces
|
|
101
|
+
└── sdk.spaceInvites → /space-invite
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Key design decisions:**
|
|
105
|
+
|
|
106
|
+
- The backend base URL is baked into the SDK at build time and is not configured by consumers.
|
|
107
|
+
- Your API key is passed once at initialization and injected automatically as the `x-sdk-key` header on every request.
|
|
108
|
+
- All request failures are normalized into typed `OdysseyError` objects with stable `name` and `code` fields.
|
|
109
|
+
- Debug logging is opt-in and silent by default.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Configuration
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
import {
|
|
117
|
+
createOrganizationSDK,
|
|
118
|
+
OrganizationSDKConfig,
|
|
119
|
+
} from "@newgameplusinc/odyssey-organization-sdk";
|
|
120
|
+
|
|
121
|
+
const sdk = createOrganizationSDK({
|
|
122
|
+
apiKey: "your-api-key",
|
|
123
|
+
timeout: 60_000,
|
|
124
|
+
});
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
| Option | Type | Required | Default | Description |
|
|
128
|
+
| --------- | -------- | -------- | ------- | -------------------------------------------------------- |
|
|
129
|
+
| `apiKey` | `string` | Yes | - | API key sent as the `x-sdk-key` header on every request. |
|
|
130
|
+
| `timeout` | `number` | No | `30000` | Request timeout in milliseconds. |
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Error Handling
|
|
135
|
+
|
|
136
|
+
All SDK errors are instances of `OdysseyError`. You can use `isOdysseyError()` to safely narrow the type in catch blocks.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
import { isOdysseyError } from "@newgameplusinc/odyssey-organization-sdk";
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
const organization = await sdk.organization.getById("org-id");
|
|
143
|
+
} catch (err) {
|
|
144
|
+
if (isOdysseyError(err)) {
|
|
145
|
+
console.log(err.name);
|
|
146
|
+
console.log(err.code);
|
|
147
|
+
console.log(err.message);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Error Types
|
|
153
|
+
|
|
154
|
+
| `err.name` | `err.code` | When it is thrown |
|
|
155
|
+
| ------------------------ | ------------------ | ---------------------------------------------------------------------- |
|
|
156
|
+
| `OdysseyConfigError` | `INVALID_CONFIG` | API key is missing or the SDK build has no base URL configured. |
|
|
157
|
+
| `OdysseyAuthError` | `AUTH_ERROR` | Server returns `401` or `403`. |
|
|
158
|
+
| `OdysseyValidationError` | `VALIDATION_ERROR` | Server returns `400` or `422`. |
|
|
159
|
+
| `OdysseyUploadError` | `UPLOAD_ERROR` | Upload-specific failure category exported by the SDK error helpers. |
|
|
160
|
+
| `OdysseyRequestError` | `REQUEST_ERROR` | Network failure, timeout, or any other non-validation request failure. |
|
|
161
|
+
| `OdysseySDKError` | `SDK_ERROR` | Generic fallback error. |
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Debug Logging
|
|
166
|
+
|
|
167
|
+
The SDK ships with a built-in debug logger that is silent by default. Enable it to see outgoing requests, response statuses, and module-level operations.
|
|
168
|
+
|
|
169
|
+
**In Node.js:**
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
ODYSSEY_DEBUG=true node your-script.js
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**In the browser:**
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
window.ODYSSEY_DEBUG = true;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Example log output:
|
|
182
|
+
|
|
183
|
+
```text
|
|
184
|
+
[14:23:01.452][SDK:HTTP] → POST /organizations
|
|
185
|
+
[14:23:01.891][SDK:HTTP] ← 201 /organizations
|
|
186
|
+
[14:23:01.892][SDK:Organization] create { id: "..." }
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## API Reference
|
|
192
|
+
|
|
193
|
+
### Health
|
|
194
|
+
|
|
195
|
+
#### `sdk.health.getHealth()`
|
|
196
|
+
|
|
197
|
+
Check if the backend service is running.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
const health = await sdk.health.getHealth();
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Returns:** `Promise<HealthResponse>`
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
#### `sdk.health.getRedisHealth()`
|
|
208
|
+
|
|
209
|
+
Check Redis health and latency.
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
const redis = await sdk.health.getRedisHealth();
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Returns:** `Promise<RedisHealthResponse>`
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
#### `sdk.health.testRedis()`
|
|
220
|
+
|
|
221
|
+
Run a Redis test operation.
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
await sdk.health.testRedis();
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
**Returns:** `Promise<void>`
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
### Organizations
|
|
232
|
+
|
|
233
|
+
#### `sdk.organization.create(data)`
|
|
234
|
+
|
|
235
|
+
Create a new organization.
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const organization = await sdk.organization.create({
|
|
239
|
+
name: "New Game Plus",
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
**Returns:** `Promise<Organization>`
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
#### `sdk.organization.getAll(query?)`
|
|
248
|
+
|
|
249
|
+
Fetch paginated organizations.
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
const result = await sdk.organization.getAll({
|
|
253
|
+
page: 1,
|
|
254
|
+
limit: 10,
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**Returns:** `Promise<OrganizationListResult>`
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
#### `sdk.organization.getById(id)`
|
|
263
|
+
|
|
264
|
+
Fetch a single organization by ID.
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
const organization = await sdk.organization.getById("org-id");
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Returns:** `Promise<Organization>`
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
#### `sdk.organization.getByUser()`
|
|
275
|
+
|
|
276
|
+
Fetch organizations for the current authenticated user.
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const organizations = await sdk.organization.getByUser();
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**Returns:** `Promise<OrganizationByUserResult[]>`
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
#### `sdk.organization.getUsers(orgId)`
|
|
287
|
+
|
|
288
|
+
Fetch organization users by organization ID.
|
|
289
|
+
|
|
290
|
+
```typescript
|
|
291
|
+
const users = await sdk.organization.getUsers("org-id");
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Returns:** `Promise<OrganizationUser[]>`
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
#### `sdk.organization.update(id, data)`
|
|
299
|
+
|
|
300
|
+
Update organization fields.
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
const updated = await sdk.organization.update("org-id", {
|
|
304
|
+
name: "Updated Name",
|
|
305
|
+
domain: "new-domain",
|
|
306
|
+
logoSmallUrl: "https://example.com/logo.png",
|
|
307
|
+
});
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Returns:** `Promise<Organization>`
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
#### `sdk.organization.updateUser(userId, data)`
|
|
315
|
+
|
|
316
|
+
Update an organization user.
|
|
317
|
+
|
|
318
|
+
```typescript
|
|
319
|
+
const user = await sdk.organization.updateUser("user-id", {
|
|
320
|
+
roleId: "role-id",
|
|
321
|
+
avatarReadyPlayerMeImg: "https://example.com/avatar.png",
|
|
322
|
+
});
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
**Returns:** `Promise<OrganizationUser>`
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
#### `sdk.organization.delete(id)`
|
|
330
|
+
|
|
331
|
+
Delete an organization.
|
|
332
|
+
|
|
333
|
+
```typescript
|
|
334
|
+
const deleted = await sdk.organization.delete("org-id");
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Returns:** `Promise<Organization>`
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
#### `sdk.organization.deleteUser(userId)`
|
|
342
|
+
|
|
343
|
+
Delete an organization user.
|
|
344
|
+
|
|
345
|
+
```typescript
|
|
346
|
+
const deleted = await sdk.organization.deleteUser("user-id");
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
**Returns:** `Promise<OrganizationUser>`
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
### Organization Invites
|
|
354
|
+
|
|
355
|
+
#### `sdk.organizationInvites.create(data)`
|
|
356
|
+
|
|
357
|
+
Create an organization invite.
|
|
358
|
+
|
|
359
|
+
```typescript
|
|
360
|
+
const invite = await sdk.organizationInvites.create({
|
|
361
|
+
orgId: "org-id",
|
|
362
|
+
email: "user@example.com",
|
|
363
|
+
roleId: "role-id",
|
|
364
|
+
});
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Returns:** `Promise<OrganizationInvite>`
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
#### `sdk.organizationInvites.accept(inviteId)`
|
|
372
|
+
|
|
373
|
+
Accept an organization invite.
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
const invite = await sdk.organizationInvites.accept("invite-link-id");
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Returns:** `Promise<OrganizationInvite>`
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
#### `sdk.organizationInvites.reject(inviteId)`
|
|
384
|
+
|
|
385
|
+
Reject an organization invite.
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
const invite = await sdk.organizationInvites.reject("invite-link-id");
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Returns:** `Promise<OrganizationInvite>`
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
#### `sdk.organizationInvites.getPendingUsers(orgId)`
|
|
396
|
+
|
|
397
|
+
Fetch pending invites for an organization.
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
const invites = await sdk.organizationInvites.getPendingUsers("org-id");
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
**Returns:** `Promise<OrganizationInvite[]>`
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
#### `sdk.organizationInvites.getPendingUserByInviteId(inviteId)`
|
|
408
|
+
|
|
409
|
+
Fetch a pending organization invite by invite link ID.
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
const invite =
|
|
413
|
+
await sdk.organizationInvites.getPendingUserByInviteId("invite-link-id");
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
**Returns:** `Promise<OrganizationInvite | null>`
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
### Projects
|
|
421
|
+
|
|
422
|
+
#### `sdk.projects.create(data)`
|
|
423
|
+
|
|
424
|
+
Create a project.
|
|
425
|
+
|
|
426
|
+
```typescript
|
|
427
|
+
const project = await sdk.projects.create({
|
|
428
|
+
orgId: "org-id",
|
|
429
|
+
name: "Project Alpha",
|
|
430
|
+
description: "Primary experience",
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
**Returns:** `Promise<Project>`
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
#### `sdk.projects.getByOrg(orgId, query?)`
|
|
439
|
+
|
|
440
|
+
Fetch paginated projects by organization ID.
|
|
441
|
+
|
|
442
|
+
```typescript
|
|
443
|
+
const projects = await sdk.projects.getByOrg("org-id", {
|
|
444
|
+
page: 1,
|
|
445
|
+
limit: 10,
|
|
446
|
+
});
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
**Returns:** `Promise<ProjectListResult>`
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
#### `sdk.projects.getById(projectId)`
|
|
454
|
+
|
|
455
|
+
Fetch a project by ID.
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
const project = await sdk.projects.getById("project-id");
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
**Returns:** `Promise<Project>`
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
#### `sdk.projects.update(projectId, data)`
|
|
466
|
+
|
|
467
|
+
Update a project.
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
const project = await sdk.projects.update("project-id", {
|
|
471
|
+
name: "Updated Project",
|
|
472
|
+
description: "Updated description",
|
|
473
|
+
isActive: true,
|
|
474
|
+
});
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Returns:** `Promise<Project>`
|
|
478
|
+
|
|
479
|
+
---
|
|
480
|
+
|
|
481
|
+
#### `sdk.projects.delete(projectId)`
|
|
482
|
+
|
|
483
|
+
Delete a project.
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
const deleted = await sdk.projects.delete("project-id");
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**Returns:** `Promise<Project>`
|
|
490
|
+
|
|
491
|
+
---
|
|
492
|
+
|
|
493
|
+
### Spaces
|
|
494
|
+
|
|
495
|
+
#### `sdk.spaces.create(data)`
|
|
496
|
+
|
|
497
|
+
Create a space.
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
const space = await sdk.spaces.create({
|
|
501
|
+
orgId: "org-id",
|
|
502
|
+
name: "Main Lobby",
|
|
503
|
+
spaceTemplateId: "template-id",
|
|
504
|
+
unrealProject: {
|
|
505
|
+
unrealProjectId: "uproject-id",
|
|
506
|
+
unrealProjectVersionId: "uproject-version-id",
|
|
507
|
+
},
|
|
508
|
+
});
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
**Returns:** `Promise<Space>`
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
#### `sdk.spaces.getByOrg(orgId)`
|
|
516
|
+
|
|
517
|
+
Fetch spaces by organization ID.
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
const spaces = await sdk.spaces.getByOrg("org-id");
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
**Returns:** `Promise<Space[]>`
|
|
524
|
+
|
|
525
|
+
---
|
|
526
|
+
|
|
527
|
+
#### `sdk.spaces.getByProject(projectId)`
|
|
528
|
+
|
|
529
|
+
Fetch spaces by project ID.
|
|
530
|
+
|
|
531
|
+
```typescript
|
|
532
|
+
const spaces = await sdk.spaces.getByProject("project-id");
|
|
533
|
+
```
|
|
534
|
+
|
|
535
|
+
**Returns:** `Promise<Space[]>`
|
|
536
|
+
|
|
537
|
+
---
|
|
538
|
+
|
|
539
|
+
#### `sdk.spaces.getUsers(spaceId)`
|
|
540
|
+
|
|
541
|
+
Fetch users for a space.
|
|
542
|
+
|
|
543
|
+
```typescript
|
|
544
|
+
const users = await sdk.spaces.getUsers("space-id");
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
**Returns:** `Promise<SpaceUser[]>`
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
#### `sdk.spaces.update(spaceId, data)`
|
|
552
|
+
|
|
553
|
+
Update a space.
|
|
554
|
+
|
|
555
|
+
```typescript
|
|
556
|
+
const updated = await sdk.spaces.update("space-id", {
|
|
557
|
+
name: "Updated Space",
|
|
558
|
+
description: "Updated description",
|
|
559
|
+
thumb: "https://example.com/thumb.png",
|
|
560
|
+
});
|
|
561
|
+
```
|
|
562
|
+
|
|
563
|
+
**Returns:** `Promise<Space>`
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
#### `sdk.spaces.updateSetting(spaceId, data)`
|
|
568
|
+
|
|
569
|
+
Update a space setting record.
|
|
570
|
+
|
|
571
|
+
```typescript
|
|
572
|
+
const setting = await sdk.spaces.updateSetting("space-id", {
|
|
573
|
+
isPublic: true,
|
|
574
|
+
allowAnonymousUsers: false,
|
|
575
|
+
odysseyMobileControls: "ON",
|
|
576
|
+
avatarControlSystem: "EVENT_MODE",
|
|
577
|
+
});
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
**Returns:** `Promise<SpaceSetting>`
|
|
581
|
+
|
|
582
|
+
---
|
|
583
|
+
|
|
584
|
+
#### `sdk.spaces.updateUser(userId, data)`
|
|
585
|
+
|
|
586
|
+
Update a space user.
|
|
587
|
+
|
|
588
|
+
```typescript
|
|
589
|
+
const user = await sdk.spaces.updateUser("space-user-id", {
|
|
590
|
+
roleId: "role-id",
|
|
591
|
+
avatarUrl: "https://example.com/avatar.png",
|
|
592
|
+
});
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
**Returns:** `Promise<SpaceUser>`
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
#### `sdk.spaces.delete(spaceId)`
|
|
600
|
+
|
|
601
|
+
Delete a space.
|
|
602
|
+
|
|
603
|
+
```typescript
|
|
604
|
+
const deleted = await sdk.spaces.delete("space-id");
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
**Returns:** `Promise<Space>`
|
|
608
|
+
|
|
609
|
+
---
|
|
610
|
+
|
|
611
|
+
#### `sdk.spaces.deleteUser(userId)`
|
|
612
|
+
|
|
613
|
+
Delete a space user.
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
const deleted = await sdk.spaces.deleteUser("space-user-id");
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
**Returns:** `Promise<SpaceUser>`
|
|
620
|
+
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
### Space Invites
|
|
624
|
+
|
|
625
|
+
#### `sdk.spaceInvites.create(data)`
|
|
626
|
+
|
|
627
|
+
Create a space invite.
|
|
628
|
+
|
|
629
|
+
```typescript
|
|
630
|
+
const invite = await sdk.spaceInvites.create({
|
|
631
|
+
spaceId: "space-id",
|
|
632
|
+
email: "user@example.com",
|
|
633
|
+
roleId: "role-id",
|
|
634
|
+
});
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
**Returns:** `Promise<SpaceInvite>`
|
|
638
|
+
|
|
639
|
+
---
|
|
640
|
+
|
|
641
|
+
#### `sdk.spaceInvites.accept(inviteId)`
|
|
642
|
+
|
|
643
|
+
Accept a space invite.
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
const invite = await sdk.spaceInvites.accept("invite-link-id");
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
**Returns:** `Promise<SpaceInvite>`
|
|
650
|
+
|
|
651
|
+
---
|
|
652
|
+
|
|
653
|
+
#### `sdk.spaceInvites.reject(inviteId)`
|
|
654
|
+
|
|
655
|
+
Reject a space invite.
|
|
656
|
+
|
|
657
|
+
```typescript
|
|
658
|
+
const invite = await sdk.spaceInvites.reject("invite-link-id");
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
**Returns:** `Promise<SpaceInvite>`
|
|
662
|
+
|
|
663
|
+
---
|
|
664
|
+
|
|
665
|
+
#### `sdk.spaceInvites.getPendingUsers(spaceId)`
|
|
666
|
+
|
|
667
|
+
Fetch pending invites for a space.
|
|
668
|
+
|
|
669
|
+
```typescript
|
|
670
|
+
const invites = await sdk.spaceInvites.getPendingUsers("space-id");
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
**Returns:** `Promise<SpaceInvite[]>`
|
|
674
|
+
|
|
675
|
+
---
|
|
676
|
+
|
|
677
|
+
#### `sdk.spaceInvites.getPendingUserByInviteId(inviteId)`
|
|
678
|
+
|
|
679
|
+
Fetch a pending space invite by invite link ID.
|
|
680
|
+
|
|
681
|
+
```typescript
|
|
682
|
+
const invite =
|
|
683
|
+
await sdk.spaceInvites.getPendingUserByInviteId("invite-link-id");
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
**Returns:** `Promise<SpaceInvite | null>`
|
|
687
|
+
|
|
688
|
+
---
|
|
689
|
+
|
|
690
|
+
## Types Reference
|
|
691
|
+
|
|
692
|
+
All types are exported directly from the package root:
|
|
693
|
+
|
|
694
|
+
```typescript
|
|
695
|
+
import type { ... } from "@newgameplusinc/odyssey-organization-sdk";
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
### Config
|
|
701
|
+
|
|
702
|
+
```typescript
|
|
703
|
+
type OrganizationSDKConfig = {
|
|
704
|
+
apiKey: string;
|
|
705
|
+
timeout?: number;
|
|
706
|
+
};
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
---
|
|
710
|
+
|
|
711
|
+
### Common
|
|
712
|
+
|
|
713
|
+
```typescript
|
|
714
|
+
type PaginationQuery = {
|
|
715
|
+
page?: number;
|
|
716
|
+
limit?: number;
|
|
717
|
+
};
|
|
718
|
+
|
|
719
|
+
type PaginationMeta = {
|
|
720
|
+
total: number;
|
|
721
|
+
page: number;
|
|
722
|
+
limit: number;
|
|
723
|
+
totalPages: number;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
type InviteStatus = "PENDING" | "ACCEPTED" | "REJECTED" | "EXPIRES";
|
|
727
|
+
|
|
728
|
+
type InviteType = "EMAIL" | "LINK";
|
|
729
|
+
|
|
730
|
+
type OdysseyMobileControls = "ON" | "OFF" | "JOYSTICK_ONLY";
|
|
731
|
+
|
|
732
|
+
type AvatarType = "STANDARD" | "AEC";
|
|
733
|
+
|
|
734
|
+
type AvatarControlSystem = "EVENT_MODE" | "GAME_MODE" | "FLIGHT_MODE";
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
---
|
|
738
|
+
|
|
739
|
+
### Organization Types
|
|
740
|
+
|
|
741
|
+
```typescript
|
|
742
|
+
type Organization = {
|
|
743
|
+
id: string;
|
|
744
|
+
name: string;
|
|
745
|
+
domain: string;
|
|
746
|
+
logoSmallUrl: string | null;
|
|
747
|
+
createdAt: string;
|
|
748
|
+
updatedAt: string;
|
|
749
|
+
};
|
|
750
|
+
|
|
751
|
+
type OrganizationUser = {
|
|
752
|
+
id: string;
|
|
753
|
+
orgId: string;
|
|
754
|
+
email: string;
|
|
755
|
+
roleId: string;
|
|
756
|
+
avatarReadyPlayerMeImg: string | null;
|
|
757
|
+
createdAt: string;
|
|
758
|
+
updatedAt: string;
|
|
759
|
+
organization?: Organization;
|
|
760
|
+
};
|
|
761
|
+
|
|
762
|
+
type OrganizationConfiguration = {
|
|
763
|
+
id: string;
|
|
764
|
+
orgId: string;
|
|
765
|
+
unrealImageId: string;
|
|
766
|
+
unrealImageRepo: string;
|
|
767
|
+
workloadClusterProvider: string;
|
|
768
|
+
createdAt: string;
|
|
769
|
+
updatedAt: string;
|
|
770
|
+
organization?: Organization;
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
type OrganizationByUserResult = {
|
|
774
|
+
organization: Organization;
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
type CreateOrganizationInput = {
|
|
778
|
+
name: string;
|
|
779
|
+
};
|
|
780
|
+
|
|
781
|
+
type UpdateOrganizationInput = {
|
|
782
|
+
name?: string | null;
|
|
783
|
+
domain?: string | null;
|
|
784
|
+
logoSmallUrl?: string | null;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
type UpdateOrganizationUserInput = {
|
|
788
|
+
roleId?: string;
|
|
789
|
+
avatarReadyPlayerMeImg?: string;
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
type OrganizationInvite = {
|
|
793
|
+
id: string;
|
|
794
|
+
orgId: string;
|
|
795
|
+
email: string;
|
|
796
|
+
roleId: string;
|
|
797
|
+
inviteLinkId: string;
|
|
798
|
+
avatarReadyPlayerMeImg: string | null;
|
|
799
|
+
actionAt: string | null;
|
|
800
|
+
status: InviteStatus;
|
|
801
|
+
type: InviteType;
|
|
802
|
+
createdAt: string;
|
|
803
|
+
updatedAt: string;
|
|
804
|
+
organization?: Organization;
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
type CreateOrganizationInviteInput = {
|
|
808
|
+
orgId: string;
|
|
809
|
+
email: string;
|
|
810
|
+
roleId: string;
|
|
811
|
+
};
|
|
812
|
+
|
|
813
|
+
type OrganizationListResult = {
|
|
814
|
+
data: Organization[];
|
|
815
|
+
meta: PaginationMeta;
|
|
816
|
+
};
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
### Project Types
|
|
822
|
+
|
|
823
|
+
```typescript
|
|
824
|
+
type Project = {
|
|
825
|
+
id: string;
|
|
826
|
+
orgId: string;
|
|
827
|
+
name: string;
|
|
828
|
+
description: string | null;
|
|
829
|
+
isActive: boolean;
|
|
830
|
+
createdAt: string;
|
|
831
|
+
updatedAt: string;
|
|
832
|
+
organization?: Organization;
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
type CreateProjectInput = {
|
|
836
|
+
orgId: string;
|
|
837
|
+
name: string;
|
|
838
|
+
description?: string | null;
|
|
839
|
+
};
|
|
840
|
+
|
|
841
|
+
type UpdateProjectInput = {
|
|
842
|
+
name?: string;
|
|
843
|
+
description?: string | null;
|
|
844
|
+
isActive?: boolean;
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
type ProjectListResult = {
|
|
848
|
+
data: Project[];
|
|
849
|
+
meta: PaginationMeta;
|
|
850
|
+
};
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
---
|
|
854
|
+
|
|
855
|
+
### Space Types
|
|
856
|
+
|
|
857
|
+
```typescript
|
|
858
|
+
type UnrealProject = {
|
|
859
|
+
unrealProjectId: string;
|
|
860
|
+
unrealProjectVersionId: string;
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
type Space = {
|
|
864
|
+
id: string;
|
|
865
|
+
orgId: string;
|
|
866
|
+
projectId: string;
|
|
867
|
+
name: string;
|
|
868
|
+
description: string | null;
|
|
869
|
+
unrealProject: UnrealProject | Record<string, unknown>;
|
|
870
|
+
currentParticipantSum: number;
|
|
871
|
+
spaceTemplateId: string;
|
|
872
|
+
thumb: string | null;
|
|
873
|
+
spaceItemSum: number;
|
|
874
|
+
createdAt: string;
|
|
875
|
+
updatedAt: string;
|
|
876
|
+
organization?: Organization;
|
|
877
|
+
spaceSetting?: SpaceSetting | null;
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
type SpaceSetting = {
|
|
881
|
+
id: string;
|
|
882
|
+
spaceId: string;
|
|
883
|
+
isPublic: boolean;
|
|
884
|
+
afkTimer: number;
|
|
885
|
+
maxSessionLength: number;
|
|
886
|
+
allowAnonymousUsers: boolean;
|
|
887
|
+
allowEmbed: boolean;
|
|
888
|
+
allowConfigurationToolbarForAllUsers: boolean;
|
|
889
|
+
disableChat: boolean;
|
|
890
|
+
disableComms: boolean;
|
|
891
|
+
enableSharding: boolean;
|
|
892
|
+
isLiveStreamActive: boolean;
|
|
893
|
+
showHelpMenu: boolean;
|
|
894
|
+
showLoadingBackground: boolean;
|
|
895
|
+
showLoadingBackgroundBlur: boolean;
|
|
896
|
+
showOdysseyEditorMenu: boolean;
|
|
897
|
+
showSpaceInformation: boolean;
|
|
898
|
+
notViewerBuddle: boolean;
|
|
899
|
+
maximumResolution?: unknown;
|
|
900
|
+
odysseyMobileControls: OdysseyMobileControls;
|
|
901
|
+
avatarType: AvatarType;
|
|
902
|
+
avatarControlSystem: AvatarControlSystem;
|
|
903
|
+
createdAt: string;
|
|
904
|
+
updatedAt: string;
|
|
905
|
+
space?: Space;
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
type SpaceUser = {
|
|
909
|
+
id: string;
|
|
910
|
+
spaceId: string;
|
|
911
|
+
email: string;
|
|
912
|
+
roleId: string;
|
|
913
|
+
isPending: boolean;
|
|
914
|
+
avatarUrl: string | null;
|
|
915
|
+
createdAt: string;
|
|
916
|
+
updatedAt: string;
|
|
917
|
+
space?: Space;
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
type SpaceInvite = {
|
|
921
|
+
id: string;
|
|
922
|
+
spaceId: string;
|
|
923
|
+
email: string;
|
|
924
|
+
roleId: string;
|
|
925
|
+
inviteLinkId: string;
|
|
926
|
+
avatarReadyPlayerMeImg: string | null;
|
|
927
|
+
actionAt: string | null;
|
|
928
|
+
status: InviteStatus;
|
|
929
|
+
type: InviteType;
|
|
930
|
+
createdAt: string;
|
|
931
|
+
updatedAt: string;
|
|
932
|
+
space?: Space;
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
type CreateSpaceInput = {
|
|
936
|
+
orgId: string;
|
|
937
|
+
name: string;
|
|
938
|
+
spaceTemplateId: string;
|
|
939
|
+
unrealProject: {
|
|
940
|
+
unrealProjectId: string;
|
|
941
|
+
unrealProjectVersionId: string;
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
type UpdateSpaceInput = {
|
|
946
|
+
name?: string;
|
|
947
|
+
description?: string | null;
|
|
948
|
+
thumb?: string | null;
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
type UpdateSpaceSettingInput = {
|
|
952
|
+
isPublic?: boolean;
|
|
953
|
+
afkTimer?: number;
|
|
954
|
+
maxSessionLength?: number;
|
|
955
|
+
allowAnonymousUsers?: boolean;
|
|
956
|
+
allowEmbed?: boolean;
|
|
957
|
+
allowConfigurationToolbarForAllUsers?: boolean;
|
|
958
|
+
disableChat?: boolean;
|
|
959
|
+
disableComms?: boolean;
|
|
960
|
+
enableSharding?: boolean;
|
|
961
|
+
isLiveStreamActive?: boolean;
|
|
962
|
+
showHelpMenu?: boolean;
|
|
963
|
+
showLoadingBackground?: boolean;
|
|
964
|
+
showLoadingBackgroundBlur?: boolean;
|
|
965
|
+
showOdysseyEditorMenu?: boolean;
|
|
966
|
+
showSpaceInformation?: boolean;
|
|
967
|
+
notViewerBuddle?: boolean;
|
|
968
|
+
maximumResolution?: unknown;
|
|
969
|
+
odysseyMobileControls?: OdysseyMobileControls;
|
|
970
|
+
avatarType?: AvatarType;
|
|
971
|
+
avatarControlSystem?: AvatarControlSystem;
|
|
972
|
+
};
|
|
973
|
+
|
|
974
|
+
type UpdateSpaceUserInput = {
|
|
975
|
+
roleId?: string;
|
|
976
|
+
avatarUrl?: string;
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
type CreateSpaceInviteInput = {
|
|
980
|
+
spaceId: string;
|
|
981
|
+
email: string;
|
|
982
|
+
roleId: string;
|
|
983
|
+
};
|
|
984
|
+
```
|
|
985
|
+
|
|
986
|
+
---
|
|
987
|
+
|
|
988
|
+
### Health Types
|
|
989
|
+
|
|
990
|
+
```typescript
|
|
991
|
+
type HealthResponse = {
|
|
992
|
+
status: string;
|
|
993
|
+
timestamp: string;
|
|
994
|
+
};
|
|
995
|
+
|
|
996
|
+
type RedisHealthResponse = {
|
|
997
|
+
status: string;
|
|
998
|
+
latencyMs?: number;
|
|
999
|
+
};
|
|
1000
|
+
```
|
|
1001
|
+
|
|
1002
|
+
---
|
|
1003
|
+
|
|
1004
|
+
### Error Types
|
|
1005
|
+
|
|
1006
|
+
```typescript
|
|
1007
|
+
interface OdysseyError extends Error {
|
|
1008
|
+
readonly code: string;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
function isOdysseyError(err: unknown): err is OdysseyError;
|
|
1012
|
+
```
|
|
1013
|
+
|
|
1014
|
+
---
|
|
1015
|
+
|
|
1016
|
+
## Versioning
|
|
1017
|
+
|
|
1018
|
+
This SDK follows semantic versioning:
|
|
1019
|
+
|
|
1020
|
+
| Bump | When |
|
|
1021
|
+
| ----------------- | ---------------------------------------------------------- |
|
|
1022
|
+
| `patch` - `x.x.1` | Bug fixes with no public API changes. |
|
|
1023
|
+
| `minor` - `x.1.0` | New methods or fields added in a backwards-compatible way. |
|
|
1024
|
+
| `major` - `2.0.0` | Breaking changes to existing method signatures or types. |
|
|
1025
|
+
|
|
1026
|
+
---
|
|
1027
|
+
|
|
1028
|
+
## License
|
|
1029
|
+
|
|
1030
|
+
MIT
|