@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.
Files changed (57) hide show
  1. package/README.md +44 -21
  2. package/dist/agui.d.cts +1 -1
  3. package/dist/agui.d.ts +1 -1
  4. package/dist/audio.d.cts +1 -1
  5. package/dist/audio.d.ts +1 -1
  6. package/dist/{chat-interaction-Ck1oMOr5.d.ts → chat-interaction-BB3ap8_u.d.ts} +8920 -6212
  7. package/dist/{chat-interaction-DqQu8Ad1.d.cts → chat-interaction-Bj1pciwo.d.cts} +8920 -6212
  8. package/dist/{chunk-P2E6LU7I.js → chunk-67QXTQVL.js} +1 -26
  9. package/dist/chunk-67QXTQVL.js.map +1 -0
  10. package/dist/chunk-6KPGCPGW.js +48 -0
  11. package/dist/chunk-6KPGCPGW.js.map +1 -0
  12. package/dist/{chunk-HRUMZ46V.js → chunk-72SWNLVD.js} +2 -1
  13. package/dist/chunk-72SWNLVD.js.map +1 -0
  14. package/dist/{chunk-R3C63RZJ.js → chunk-ZTUOB4V2.js} +1278 -218
  15. package/dist/chunk-ZTUOB4V2.js.map +1 -0
  16. package/dist/helpers.cjs +47 -0
  17. package/dist/helpers.cjs.map +1 -1
  18. package/dist/helpers.d.cts +4 -3
  19. package/dist/helpers.d.ts +4 -3
  20. package/dist/helpers.js +7 -1
  21. package/dist/helpers.js.map +1 -1
  22. package/dist/index.cjs +1389 -350
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +13 -35
  25. package/dist/index.d.ts +13 -35
  26. package/dist/index.js +112 -122
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal.cjs +1303 -252
  29. package/dist/internal.cjs.map +1 -1
  30. package/dist/internal.d.cts +338 -55
  31. package/dist/internal.d.ts +338 -55
  32. package/dist/internal.js +68 -21
  33. package/dist/internal.js.map +1 -1
  34. package/dist/member-import-D8fZr2Pd.d.cts +46 -0
  35. package/dist/member-import-YNk9MlEl.d.ts +46 -0
  36. package/dist/realtime.cjs +91 -20
  37. package/dist/realtime.cjs.map +1 -1
  38. package/dist/realtime.d.cts +34 -9
  39. package/dist/realtime.d.ts +34 -9
  40. package/dist/realtime.js +90 -20
  41. package/dist/realtime.js.map +1 -1
  42. package/dist/{revision-state-Tn2V0-zt.d.cts → revision-state-BaJTq3Or.d.ts} +271 -55
  43. package/dist/{revision-state-V5RIhte0.d.ts → revision-state-CL11FA-T.d.cts} +271 -55
  44. package/dist/schemas.cjs +58 -81
  45. package/dist/schemas.cjs.map +1 -1
  46. package/dist/schemas.d.cts +88 -225
  47. package/dist/schemas.d.ts +88 -225
  48. package/dist/schemas.js +58 -76
  49. package/dist/schemas.js.map +1 -1
  50. package/dist/{tasks-BH_i_pVb.d.cts → tasks-ByJCQ5BI.d.cts} +3003 -2508
  51. package/dist/{tasks-BH_i_pVb.d.ts → tasks-ByJCQ5BI.d.ts} +3003 -2508
  52. package/dist/{types-0c6_NGU4.d.cts → types-DlfADjPR.d.cts} +17 -2
  53. package/dist/{types-0c6_NGU4.d.ts → types-DlfADjPR.d.ts} +17 -2
  54. package/package.json +9 -7
  55. package/dist/chunk-HRUMZ46V.js.map +0 -1
  56. package/dist/chunk-P2E6LU7I.js.map +0 -1
  57. 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
- // List all workflows in a workspace
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
- // Create a new member
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
- first_name: 'Jane',
42
- last_name: 'Doe',
43
- email: 'jane@example.com',
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
- Scoped API keys are the simplest way to authenticate. Create one from workspace settings or via the SDK:
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
- Keys can be scoped to specific permissions (read-only, workspace-limited, time-expiring) using the [granular scope system](#scopes--permissions).
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
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.cjs';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.cjs';
2
2
 
3
3
  interface TranscriptMessage {
4
4
  id: string;
package/dist/agui.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.js';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.js';
2
2
 
3
3
  interface TranscriptMessage {
4
4
  id: string;
package/dist/audio.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.cjs';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.cjs';
2
2
 
3
3
  /** PCM16 helpers aligned with main-app web voice (24 kHz). */
4
4
  declare const SERVER_SAMPLE_RATE = 24000;
package/dist/audio.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as ChannelEvent } from './types-0c6_NGU4.js';
1
+ import { C as ChannelEvent } from './types-DlfADjPR.js';
2
2
 
3
3
  /** PCM16 helpers aligned with main-app web voice (24 kHz). */
4
4
  declare const SERVER_SAMPLE_RATE = 24000;