@gravity-rail/sdk 0.36.0 → 0.40.0
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 +44 -21
- package/dist/agui.d.cts +1 -1
- package/dist/agui.d.ts +1 -1
- package/dist/audio.d.cts +1 -1
- package/dist/audio.d.ts +1 -1
- package/dist/{chat-interaction-Ck1oMOr5.d.ts → chat-interaction-BB3ap8_u.d.ts} +8920 -6212
- package/dist/{chat-interaction-DqQu8Ad1.d.cts → chat-interaction-Bj1pciwo.d.cts} +8920 -6212
- package/dist/{chunk-P2E6LU7I.js → chunk-67QXTQVL.js} +1 -26
- package/dist/chunk-67QXTQVL.js.map +1 -0
- package/dist/chunk-6KPGCPGW.js +48 -0
- package/dist/chunk-6KPGCPGW.js.map +1 -0
- package/dist/{chunk-HRUMZ46V.js → chunk-72SWNLVD.js} +2 -1
- package/dist/chunk-72SWNLVD.js.map +1 -0
- package/dist/{chunk-R3C63RZJ.js → chunk-ZTUOB4V2.js} +1278 -218
- package/dist/chunk-ZTUOB4V2.js.map +1 -0
- package/dist/helpers.cjs +47 -0
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.d.cts +4 -3
- package/dist/helpers.d.ts +4 -3
- package/dist/helpers.js +7 -1
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +1389 -350
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -35
- package/dist/index.d.ts +13 -35
- package/dist/index.js +112 -122
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs +1303 -252
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +338 -55
- package/dist/internal.d.ts +338 -55
- package/dist/internal.js +68 -21
- package/dist/internal.js.map +1 -1
- package/dist/member-import-D8fZr2Pd.d.cts +46 -0
- package/dist/member-import-YNk9MlEl.d.ts +46 -0
- package/dist/realtime.cjs +91 -20
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.d.cts +34 -9
- package/dist/realtime.d.ts +34 -9
- package/dist/realtime.js +90 -20
- package/dist/realtime.js.map +1 -1
- package/dist/{revision-state-Tn2V0-zt.d.cts → revision-state-BaJTq3Or.d.ts} +271 -55
- package/dist/{revision-state-V5RIhte0.d.ts → revision-state-CL11FA-T.d.cts} +271 -55
- package/dist/schemas.cjs +58 -81
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +88 -225
- package/dist/schemas.d.ts +88 -225
- package/dist/schemas.js +58 -76
- package/dist/schemas.js.map +1 -1
- package/dist/{tasks-BH_i_pVb.d.cts → tasks-ByJCQ5BI.d.cts} +3003 -2508
- package/dist/{tasks-BH_i_pVb.d.ts → tasks-ByJCQ5BI.d.ts} +3003 -2508
- package/dist/{types-0c6_NGU4.d.cts → types-DlfADjPR.d.cts} +17 -2
- package/dist/{types-0c6_NGU4.d.ts → types-DlfADjPR.d.ts} +17 -2
- package/package.json +9 -7
- package/dist/chunk-HRUMZ46V.js.map +0 -1
- package/dist/chunk-P2E6LU7I.js.map +0 -1
- package/dist/chunk-R3C63RZJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -22,6 +22,11 @@ npm install zod # optional, for runtime validation
|
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
25
|
+
Create an account or organization API key with the scopes your integration needs.
|
|
26
|
+
See [Authentication](https://docs.gravityrail.com/developer/guides/connect/authentication)
|
|
27
|
+
for key reach, OAuth, and step-up requirements. Keep credentials in your server's
|
|
28
|
+
environment or secrets manager; do not embed an API key in a public browser bundle.
|
|
29
|
+
|
|
25
30
|
```typescript
|
|
26
31
|
import { GravityRailClient } from '@gravity-rail/sdk';
|
|
27
32
|
|
|
@@ -30,26 +35,55 @@ const client = new GravityRailClient(
|
|
|
30
35
|
'https://api.gravityrail.com'
|
|
31
36
|
);
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
const workspaces = await client.getWorkspaces();
|
|
39
|
+
if (workspaces.length === 0) throw new Error('No workspace available');
|
|
40
|
+
const workspaceId = workspaces[0].id;
|
|
34
41
|
const workflows = await client.getWorkflows(workspaceId);
|
|
35
|
-
|
|
36
|
-
// Get active chats across every channel
|
|
37
42
|
const chats = await client.getChats(workspaceId);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use [Creating Members](https://docs.gravityrail.com/developer/guides/data/creating-members)
|
|
46
|
+
to select the appropriate creation/import endpoint and role. A direct SDK call
|
|
47
|
+
uses the request type's wire names:
|
|
38
48
|
|
|
39
|
-
|
|
49
|
+
```typescript
|
|
50
|
+
const roleId = Number(process.env.GRAVITY_RAIL_MEMBER_ROLE_ID);
|
|
51
|
+
if (!Number.isInteger(roleId) || roleId <= 0) {
|
|
52
|
+
throw new Error('Set GRAVITY_RAIL_MEMBER_ROLE_ID to an authorized role ID');
|
|
53
|
+
}
|
|
40
54
|
const member = await client.createWorkspaceMember(workspaceId, {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
role_id: roleId,
|
|
55
|
+
name: 'Integration Test',
|
|
56
|
+
email: 'integration-test@example.com',
|
|
57
|
+
memberRoleId: roleId, // an authorized role selected for the new Member
|
|
45
58
|
});
|
|
46
59
|
```
|
|
47
60
|
|
|
61
|
+
### Handle API errors
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { ApiError } from '@gravity-rail/sdk';
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
await client.getWorkflows(workspaceId);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof ApiError && error.statusCode === 403) {
|
|
70
|
+
// Check the acting identity and scopes for this workspace.
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [Error Handling](https://docs.gravityrail.com/developer/guides/connect/error-handling)
|
|
77
|
+
for status codes and safe reporting. The [SDK Reference](https://docs.gravityrail.com/sdk)
|
|
78
|
+
and [GravityRailClient](https://docs.gravityrail.com/sdk/classes/GravityRailClient)
|
|
79
|
+
reference document methods and types. This package README also supplies the
|
|
80
|
+
canonical [SDK usage guide](https://docs.gravityrail.com/developer/libraries/sdk).
|
|
81
|
+
|
|
48
82
|
## Authentication
|
|
49
83
|
|
|
50
84
|
### API Key
|
|
51
85
|
|
|
52
|
-
|
|
86
|
+
Create an account or organization API key with the required permissions:
|
|
53
87
|
|
|
54
88
|
```typescript
|
|
55
89
|
const client = new GravityRailClient(
|
|
@@ -58,7 +92,7 @@ const client = new GravityRailClient(
|
|
|
58
92
|
);
|
|
59
93
|
```
|
|
60
94
|
|
|
61
|
-
|
|
95
|
+
Select the required scopes and expiry using the [granular scope system](#scopes--permissions). Key reach depends on the issuing account or organization; a key created in workspace settings is not inherently limited to that workspace.
|
|
62
96
|
|
|
63
97
|
### OAuth2 with PKCE
|
|
64
98
|
|
|
@@ -73,17 +107,6 @@ client.setEnhancedAuthHandler(async (authInfo) => {
|
|
|
73
107
|
});
|
|
74
108
|
```
|
|
75
109
|
|
|
76
|
-
### Member Identity Switching
|
|
77
|
-
|
|
78
|
-
Act on behalf of a specific workspace member:
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
client.setActingMember(memberUuid);
|
|
82
|
-
// All subsequent requests use this member's identity
|
|
83
|
-
const myChats = await client.getChats(workspaceId);
|
|
84
|
-
client.setActingMember(undefined); // reset
|
|
85
|
-
```
|
|
86
|
-
|
|
87
110
|
## Core Concepts
|
|
88
111
|
|
|
89
112
|
Every Gravity Rail workspace is a self-contained environment with isolated data, workflows, and configuration. The SDK organizes its 500+ methods by domain:
|
package/dist/agui.d.cts
CHANGED
package/dist/agui.d.ts
CHANGED
package/dist/audio.d.cts
CHANGED
package/dist/audio.d.ts
CHANGED