@attrove/sdk 0.1.2 → 0.1.4

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 (107) hide show
  1. package/cjs/README.md +247 -0
  2. package/cjs/package.json +56 -0
  3. package/cjs/src/__mocks__/version.js +17 -0
  4. package/cjs/src/__mocks__/version.js.map +1 -0
  5. package/cjs/src/admin-client.js +221 -0
  6. package/cjs/src/admin-client.js.map +1 -0
  7. package/cjs/src/client.js +312 -0
  8. package/cjs/src/client.js.map +1 -0
  9. package/cjs/src/constants.js +69 -0
  10. package/cjs/src/constants.js.map +1 -0
  11. package/cjs/src/errors/index.js +307 -0
  12. package/cjs/src/errors/index.js.map +1 -0
  13. package/cjs/src/index.js +98 -0
  14. package/cjs/src/index.js.map +1 -0
  15. package/cjs/src/resources/conversations.js +95 -0
  16. package/cjs/src/resources/conversations.js.map +1 -0
  17. package/cjs/src/resources/index.js +17 -0
  18. package/cjs/src/resources/index.js.map +1 -0
  19. package/cjs/src/resources/integrations.js +69 -0
  20. package/cjs/src/resources/integrations.js.map +1 -0
  21. package/cjs/src/resources/messages.js +98 -0
  22. package/cjs/src/resources/messages.js.map +1 -0
  23. package/cjs/src/resources/query.js +143 -0
  24. package/cjs/src/resources/query.js.map +1 -0
  25. package/cjs/src/resources/users.js +91 -0
  26. package/cjs/src/resources/users.js.map +1 -0
  27. package/cjs/src/types/index.js +292 -0
  28. package/cjs/src/types/index.js.map +1 -0
  29. package/cjs/src/utils/fetch.js +417 -0
  30. package/cjs/src/utils/fetch.js.map +1 -0
  31. package/cjs/src/utils/index.js +12 -0
  32. package/cjs/src/utils/index.js.map +1 -0
  33. package/cjs/src/utils/streaming.js +368 -0
  34. package/cjs/src/utils/streaming.js.map +1 -0
  35. package/cjs/src/version.js +31 -0
  36. package/cjs/src/version.js.map +1 -0
  37. package/esm/README.md +247 -0
  38. package/esm/package.json +56 -0
  39. package/esm/src/__mocks__/version.js +12 -0
  40. package/esm/src/__mocks__/version.js.map +1 -0
  41. package/esm/src/admin-client.js +216 -0
  42. package/esm/src/admin-client.js.map +1 -0
  43. package/esm/src/client.js +308 -0
  44. package/esm/src/client.js.map +1 -0
  45. package/esm/src/constants.js +65 -0
  46. package/esm/src/constants.js.map +1 -0
  47. package/esm/src/errors/index.js +285 -0
  48. package/esm/src/errors/index.js.map +1 -0
  49. package/esm/src/index.js +68 -0
  50. package/esm/src/index.js.map +1 -0
  51. package/esm/src/resources/conversations.js +91 -0
  52. package/esm/src/resources/conversations.js.map +1 -0
  53. package/esm/src/resources/index.js +9 -0
  54. package/esm/src/resources/index.js.map +1 -0
  55. package/esm/src/resources/integrations.js +65 -0
  56. package/esm/src/resources/integrations.js.map +1 -0
  57. package/esm/src/resources/messages.js +94 -0
  58. package/esm/src/resources/messages.js.map +1 -0
  59. package/esm/src/resources/query.js +139 -0
  60. package/esm/src/resources/query.js.map +1 -0
  61. package/esm/src/resources/users.js +87 -0
  62. package/esm/src/resources/users.js.map +1 -0
  63. package/esm/src/types/index.js +277 -0
  64. package/esm/src/types/index.js.map +1 -0
  65. package/esm/src/utils/fetch.js +413 -0
  66. package/esm/src/utils/fetch.js.map +1 -0
  67. package/esm/src/utils/index.js +6 -0
  68. package/esm/src/utils/index.js.map +1 -0
  69. package/esm/src/utils/streaming.js +363 -0
  70. package/esm/src/utils/streaming.js.map +1 -0
  71. package/esm/src/version.js +26 -0
  72. package/esm/src/version.js.map +1 -0
  73. package/package.json +16 -9
  74. package/types/src/__mocks__/version.d.ts +8 -0
  75. package/types/src/__mocks__/version.d.ts.map +1 -0
  76. package/types/src/admin-client.d.ts +144 -0
  77. package/types/src/admin-client.d.ts.map +1 -0
  78. package/types/src/client.d.ts +233 -0
  79. package/types/src/client.d.ts.map +1 -0
  80. package/types/src/constants.d.ts +47 -0
  81. package/types/src/constants.d.ts.map +1 -0
  82. package/types/src/errors/index.d.ts +206 -0
  83. package/types/src/errors/index.d.ts.map +1 -0
  84. package/types/src/index.d.ts +65 -0
  85. package/types/src/index.d.ts.map +1 -0
  86. package/types/src/resources/conversations.d.ts +81 -0
  87. package/types/src/resources/conversations.d.ts.map +1 -0
  88. package/types/src/resources/index.d.ts +12 -0
  89. package/types/src/resources/index.d.ts.map +1 -0
  90. package/types/src/resources/integrations.d.ts +63 -0
  91. package/types/src/resources/integrations.d.ts.map +1 -0
  92. package/types/src/resources/messages.d.ts +69 -0
  93. package/types/src/resources/messages.d.ts.map +1 -0
  94. package/types/src/resources/query.d.ts +86 -0
  95. package/types/src/resources/query.d.ts.map +1 -0
  96. package/types/src/resources/users.d.ts +88 -0
  97. package/types/src/resources/users.d.ts.map +1 -0
  98. package/types/src/types/index.d.ts +807 -0
  99. package/types/src/types/index.d.ts.map +1 -0
  100. package/types/src/utils/fetch.d.ts +161 -0
  101. package/types/src/utils/fetch.d.ts.map +1 -0
  102. package/types/src/utils/index.d.ts +8 -0
  103. package/types/src/utils/index.d.ts.map +1 -0
  104. package/types/src/utils/streaming.d.ts +210 -0
  105. package/types/src/utils/streaming.d.ts.map +1 -0
  106. package/types/src/version.d.ts +21 -0
  107. package/types/src/version.d.ts.map +1 -0
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Attrove Client
3
+ *
4
+ * Main entry point for the Attrove SDK. Provides a simple, intuitive API
5
+ * for accessing user context through connected integrations.
6
+ */
7
+ import { StreamOptions, StreamResult } from './utils/streaming';
8
+ import { UsersResource } from './resources/users';
9
+ import { MessagesResource } from './resources/messages';
10
+ import { ConversationsResource } from './resources/conversations';
11
+ import { IntegrationsResource } from './resources/integrations';
12
+ import { AttroveConfig, QueryOptions, QueryResponse, SearchOptions, SearchResponse } from './types';
13
+ /**
14
+ * The Attrove client for accessing user context.
15
+ *
16
+ * This is the main entry point for the Attrove SDK. It provides methods for:
17
+ * - Querying user context with AI (query, search)
18
+ * - Streaming query responses in real-time
19
+ * - Accessing user data, messages, conversations, and integrations
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { Attrove } from '@attrove/sdk';
24
+ *
25
+ * const attrove = new Attrove({
26
+ * apiKey: 'sk_...',
27
+ * userId: 'user-uuid'
28
+ * });
29
+ *
30
+ * // Query user's context
31
+ * const response = await attrove.query('What meetings do I have tomorrow?');
32
+ * console.log(response.answer);
33
+ *
34
+ * // Search for specific information
35
+ * const results = await attrove.search('quarterly report');
36
+ * ```
37
+ */
38
+ export declare class Attrove {
39
+ private readonly http;
40
+ private readonly config;
41
+ private readonly queryResource;
42
+ /**
43
+ * Users resource for accessing user data and sync statistics.
44
+ */
45
+ readonly users: UsersResource;
46
+ /**
47
+ * Messages resource for accessing messages from connected integrations.
48
+ */
49
+ readonly messages: MessagesResource;
50
+ /**
51
+ * Conversations resource for managing conversations and sync settings.
52
+ */
53
+ readonly conversations: ConversationsResource;
54
+ /**
55
+ * Integrations resource for managing connected services.
56
+ */
57
+ readonly integrations: IntegrationsResource;
58
+ /**
59
+ * Create a new Attrove client.
60
+ *
61
+ * @param config - Client configuration
62
+ * @throws {ValidationError} If the configuration is invalid (missing apiKey, invalid userId format, etc.)
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const attrove = new Attrove({
67
+ * apiKey: 'sk_...',
68
+ * userId: 'user-uuid',
69
+ * timeout: 60000, // 60 seconds
70
+ * onRetry: (info) => console.log(`Retrying (${info.attempt}/${info.maxRetries})...`)
71
+ * });
72
+ * ```
73
+ */
74
+ constructor(config: AttroveConfig);
75
+ /**
76
+ * Query the user's unified context with AI.
77
+ *
78
+ * This is the primary method for asking questions about the user's data.
79
+ * It performs semantic search across all connected integrations and returns
80
+ * an AI-generated answer based on the relevant context.
81
+ *
82
+ * @param prompt - The natural language question to answer
83
+ * @param options - Query options including history, filters, etc.
84
+ * @returns AI-generated answer with source references
85
+ *
86
+ * @throws {AuthenticationError} If the API key is invalid or expired
87
+ * @throws {ValidationError} If the request parameters are invalid
88
+ * @throws {RateLimitError} If rate limits are exceeded
89
+ * @throws {NetworkError} If unable to reach the API
90
+ * @throws {ServerError} If the server encounters an error
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * // Simple query
95
+ * const response = await attrove.query('What did Sarah say about the Q4 budget?');
96
+ * console.log(response.answer);
97
+ *
98
+ * // Multi-turn conversation
99
+ * let history: ConversationMessage[] = [];
100
+ *
101
+ * const first = await attrove.query('What meetings do I have tomorrow?');
102
+ * history = first.history;
103
+ *
104
+ * const followUp = await attrove.query('Who is attending?', { history });
105
+ * console.log(followUp.answer);
106
+ * ```
107
+ */
108
+ query(prompt: string, options?: QueryOptions): Promise<QueryResponse>;
109
+ /**
110
+ * Semantic search across the user's context.
111
+ *
112
+ * Returns raw matching messages grouped by conversation, without AI summarization.
113
+ * Use this when you need full control over how results are displayed.
114
+ *
115
+ * @param query - The search query (semantic, not keyword-based)
116
+ * @param options - Search options including filters, date range, etc.
117
+ * @returns Matching messages grouped by conversation
118
+ *
119
+ * @throws {AuthenticationError} If the API key is invalid or expired
120
+ * @throws {ValidationError} If the request parameters are invalid
121
+ * @throws {RateLimitError} If rate limits are exceeded
122
+ * @throws {NetworkError} If unable to reach the API
123
+ * @throws {ServerError} If the server encounters an error
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * const results = await attrove.search('quarterly report', {
128
+ * afterDate: '2024-01-01T00:00:00Z',
129
+ * includeBodyText: true
130
+ * });
131
+ *
132
+ * for (const [convId, conv] of Object.entries(results.conversations)) {
133
+ * console.log(`Conversation: ${conv.conversation_name}`);
134
+ * for (const [threadId, messages] of Object.entries(conv.threads)) {
135
+ * console.log(` Thread ${threadId}: ${messages.length} messages`);
136
+ * }
137
+ * }
138
+ * ```
139
+ */
140
+ search(query: string, options?: SearchOptions): Promise<SearchResponse>;
141
+ /**
142
+ * Stream a query response in real-time.
143
+ *
144
+ * Connects to the WebSocket endpoint and streams the AI-generated answer
145
+ * as it's being generated. Useful for displaying results progressively.
146
+ *
147
+ * @param prompt - The natural language question to answer
148
+ * @param options - Query and streaming options
149
+ * @returns Stream result with full answer and metadata
150
+ *
151
+ * @throws {AuthenticationError} If the API key is invalid or expired
152
+ * @throws {NetworkError} If WebSocket connection fails
153
+ * @throws {TimeoutError} If connection times out
154
+ * @throws {AttroveError} If the server returns an error
155
+ *
156
+ * @example
157
+ * ```ts
158
+ * const result = await attrove.stream('What happened in the meeting?', {
159
+ * onChunk: (chunk) => process.stdout.write(chunk),
160
+ * onState: (state) => console.log('State:', state),
161
+ * });
162
+ *
163
+ * console.log('\\nFull answer:', result.answer);
164
+ * ```
165
+ */
166
+ stream(prompt: string, options?: QueryOptions & StreamOptions): Promise<StreamResult>;
167
+ /**
168
+ * Get meeting preparation brief.
169
+ *
170
+ * Retrieves context about attendees, recent conversations, and relevant
171
+ * information to help prepare for an upcoming meeting.
172
+ *
173
+ * @experimental This method is not yet implemented and will throw an error.
174
+ *
175
+ * @param meetingId - Meeting ID (UUID format)
176
+ * @returns Meeting brief with attendee info and relevant context
177
+ *
178
+ * @throws {Error} Always throws - not yet implemented
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * // Not yet available
183
+ * const brief = await attrove.brief('meeting-uuid-here');
184
+ * console.log(brief.summary);
185
+ * console.log('Attendees:', brief.attendees);
186
+ * ```
187
+ */
188
+ brief(meetingId: string): Promise<unknown>;
189
+ /**
190
+ * Get information about an entity (person, company, etc.).
191
+ *
192
+ * Retrieves profile information and interaction history for an entity
193
+ * identified from the user's communications.
194
+ *
195
+ * @experimental This method is not yet implemented and will throw an error.
196
+ *
197
+ * @param entityId - Entity ID (UUID format)
198
+ * @returns Entity profile with interaction history
199
+ *
200
+ * @throws {Error} Always throws - not yet implemented
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * // Not yet available
205
+ * const entity = await attrove.entity('entity-uuid');
206
+ * console.log(`${entity.name}: ${entity.message_count} messages`);
207
+ * ```
208
+ */
209
+ entity(entityId: string): Promise<unknown>;
210
+ /**
211
+ * Get a conversation thread.
212
+ *
213
+ * Retrieves all messages in a specific conversation thread.
214
+ *
215
+ * @experimental This method is not yet implemented and will throw an error.
216
+ *
217
+ * @param conversationId - Conversation ID (UUID format)
218
+ * @returns Conversation thread with messages
219
+ *
220
+ * @throws {Error} Always throws - not yet implemented
221
+ *
222
+ * @example
223
+ * ```ts
224
+ * // Not yet available
225
+ * const thread = await attrove.thread('conversation-uuid-here');
226
+ * for (const msg of thread.messages) {
227
+ * console.log(`${msg.sender_name}: ${msg.body_text}`);
228
+ * }
229
+ * ```
230
+ */
231
+ thread(conversationId: string): Promise<unknown>;
232
+ }
233
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAmB,aAAa,EAAE,YAAY,EAAqB,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAIhE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAGf,MAAM,SAAS,CAAC;AA6DjB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4E;IACnG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAE9C;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,qBAAqB,CAAC;IAE9C;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAE5C;;;;;;;;;;;;;;;OAeG;gBACS,MAAM,EAAE,aAAa;IA8BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAI3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IAI7E;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,MAAM,CACV,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,YAAY,GAAG,aAAkB,GACzC,OAAO,CAAC,YAAY,CAAC;IAoCxB;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhD;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKhD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAIvD"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SDK Constants
3
+ *
4
+ * Centralized constants used across the SDK. Consolidating these ensures
5
+ * consistency and makes maintenance easier.
6
+ */
7
+ /**
8
+ * SDK version string.
9
+ *
10
+ * This version is updated by the release process. Keep it in sync with
11
+ * the version in package.json. For programmatic access, use `getVersion()`
12
+ * from './version'.
13
+ */
14
+ export declare const SDK_VERSION = "0.1.3";
15
+ /**
16
+ * Default API base URL for Attrove services.
17
+ */
18
+ export declare const DEFAULT_BASE_URL = "https://api.attrove.com";
19
+ /**
20
+ * Default request timeout in milliseconds.
21
+ */
22
+ export declare const DEFAULT_TIMEOUT = 30000;
23
+ /**
24
+ * Default number of retry attempts for failed requests.
25
+ */
26
+ export declare const DEFAULT_MAX_RETRIES = 3;
27
+ /**
28
+ * Initial delay for retry backoff in milliseconds.
29
+ */
30
+ export declare const INITIAL_RETRY_DELAY = 1000;
31
+ /**
32
+ * HTTP status codes that trigger automatic retries.
33
+ */
34
+ export declare const RETRY_STATUS_CODES: readonly [408, 429, 500, 502, 503, 504];
35
+ /**
36
+ * Set of retryable status codes for O(1) lookup.
37
+ */
38
+ export declare const RETRYABLE_STATUS_SET: ReadonlySet<number>;
39
+ /**
40
+ * WebSocket close code descriptions for better error messages.
41
+ */
42
+ export declare const WS_CLOSE_CODES: Record<number, string>;
43
+ /**
44
+ * Get a human-readable description for a WebSocket close code.
45
+ */
46
+ export declare function getWsCloseReason(code: number): string;
47
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,gBAAgB,4BAA4B,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,kBAAkB,yCAA0C,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAA+B,CAAC;AAErF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAgBjD,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Attrove SDK Error Classes
3
+ *
4
+ * Provides a structured error hierarchy for handling API errors.
5
+ * Each error type maps to specific HTTP status codes and error codes.
6
+ */
7
+ import { ErrorCode, ApiError, AuthErrorCode, ValidationErrorCode, ErrorDetails } from '../types';
8
+ /**
9
+ * Base error class for all Attrove SDK errors.
10
+ *
11
+ * All SDK errors extend this class, enabling consistent error handling
12
+ * across the SDK. Use the type guards (isAttroveError, isAuthenticationError, etc.)
13
+ * for type-safe error handling.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * try {
18
+ * await attrove.query('...');
19
+ * } catch (error) {
20
+ * if (isAttroveError(error)) {
21
+ * console.log(`Error ${error.code}: ${error.message}`);
22
+ * }
23
+ * }
24
+ * ```
25
+ */
26
+ export declare class AttroveError extends Error {
27
+ /**
28
+ * Machine-readable error code for programmatic handling.
29
+ */
30
+ readonly code: ErrorCode;
31
+ /**
32
+ * HTTP status code from the API response (if applicable).
33
+ */
34
+ readonly status?: number;
35
+ /**
36
+ * Additional error details for debugging and error handling.
37
+ * Contains structured information about what went wrong.
38
+ */
39
+ readonly details?: ErrorDetails;
40
+ constructor(message: string, code: ErrorCode, status?: number, details?: ErrorDetails);
41
+ /**
42
+ * Creates an AttroveError from an API error response.
43
+ *
44
+ * @param error - The error from the API (ApiError object or string)
45
+ * @param status - Optional HTTP status code
46
+ * @returns An AttroveError instance
47
+ */
48
+ static fromApiError(error: ApiError | string, status?: number): AttroveError;
49
+ /**
50
+ * Returns a formatted string representation of the error.
51
+ */
52
+ toString(): string;
53
+ /**
54
+ * Returns a JSON-serializable representation of the error.
55
+ */
56
+ toJSON(): Record<string, unknown>;
57
+ }
58
+ /**
59
+ * Error thrown when authentication fails (401).
60
+ *
61
+ * Common causes:
62
+ * - Invalid API key
63
+ * - Expired token
64
+ * - Missing authentication header
65
+ *
66
+ * @throws {AuthenticationError}
67
+ */
68
+ export declare class AuthenticationError extends AttroveError {
69
+ constructor(message: string, code?: AuthErrorCode, details?: ErrorDetails);
70
+ }
71
+ /**
72
+ * Error thrown when the user lacks permission for an action (403).
73
+ *
74
+ * Common causes:
75
+ * - Accessing another user's data
76
+ * - Insufficient permissions for the operation
77
+ * - Resource access denied
78
+ */
79
+ export declare class AuthorizationError extends AttroveError {
80
+ constructor(message: string, code?: AuthErrorCode, details?: ErrorDetails);
81
+ }
82
+ /**
83
+ * Error thrown when a resource is not found (404).
84
+ *
85
+ * Common causes:
86
+ * - Invalid resource ID
87
+ * - Resource was deleted
88
+ * - User doesn't have access to the resource
89
+ */
90
+ export declare class NotFoundError extends AttroveError {
91
+ constructor(message: string, details?: ErrorDetails);
92
+ }
93
+ /**
94
+ * Error thrown when request validation fails (400).
95
+ *
96
+ * Common causes:
97
+ * - Invalid request parameters
98
+ * - Missing required fields
99
+ * - Invalid data format
100
+ */
101
+ export declare class ValidationError extends AttroveError {
102
+ constructor(message: string, code?: ValidationErrorCode, details?: ErrorDetails);
103
+ }
104
+ /**
105
+ * Error thrown when rate limits are exceeded (429).
106
+ *
107
+ * When this error is thrown, you should wait before retrying.
108
+ * Check the `retryAfter` property for the recommended wait time.
109
+ */
110
+ export declare class RateLimitError extends AttroveError {
111
+ /**
112
+ * Time in seconds until the rate limit resets.
113
+ * May be undefined if the server didn't provide this information.
114
+ */
115
+ readonly retryAfter?: number;
116
+ constructor(message: string, retryAfter?: number, details?: ErrorDetails);
117
+ }
118
+ /**
119
+ * Error thrown when there's a network or connectivity issue.
120
+ *
121
+ * Common causes:
122
+ * - No internet connection
123
+ * - DNS resolution failure
124
+ * - Connection refused
125
+ * - SSL/TLS errors
126
+ */
127
+ export declare class NetworkError extends AttroveError {
128
+ constructor(message: string, details?: ErrorDetails);
129
+ }
130
+ /**
131
+ * Error thrown when a request times out (408).
132
+ *
133
+ * The request took longer than the configured timeout.
134
+ * Consider increasing the timeout or retrying the request.
135
+ */
136
+ export declare class TimeoutError extends AttroveError {
137
+ constructor(message?: string, details?: ErrorDetails);
138
+ }
139
+ /**
140
+ * Error thrown when there's a server-side issue (5xx).
141
+ *
142
+ * These errors are typically transient and may be resolved by retrying.
143
+ * The SDK automatically retries on 408, 429, 500, 502, 503, and 504 errors.
144
+ * See RETRY_STATUS_CODES in constants.ts for the authoritative list.
145
+ */
146
+ export declare class ServerError extends AttroveError {
147
+ constructor(message: string, status?: number, details?: ErrorDetails);
148
+ }
149
+ /**
150
+ * Maps HTTP status codes to appropriate error classes.
151
+ *
152
+ * @param message - Error message
153
+ * @param status - HTTP status code
154
+ * @param code - Optional error code from the API
155
+ * @param details - Optional error details
156
+ * @returns An appropriate error instance for the status code
157
+ */
158
+ export declare function createErrorFromStatus(message: string, status: number, code?: ErrorCode, details?: ErrorDetails): AttroveError;
159
+ /**
160
+ * Type guard to check if an error is an AttroveError.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * try {
165
+ * await attrove.query('...');
166
+ * } catch (error) {
167
+ * if (isAttroveError(error)) {
168
+ * console.log(`Error code: ${error.code}`);
169
+ * }
170
+ * }
171
+ * ```
172
+ */
173
+ export declare function isAttroveError(error: unknown): error is AttroveError;
174
+ /**
175
+ * Type guard to check if an error is an AuthenticationError.
176
+ */
177
+ export declare function isAuthenticationError(error: unknown): error is AuthenticationError;
178
+ /**
179
+ * Type guard to check if an error is an AuthorizationError.
180
+ */
181
+ export declare function isAuthorizationError(error: unknown): error is AuthorizationError;
182
+ /**
183
+ * Type guard to check if an error is a NotFoundError.
184
+ */
185
+ export declare function isNotFoundError(error: unknown): error is NotFoundError;
186
+ /**
187
+ * Type guard to check if an error is a ValidationError.
188
+ */
189
+ export declare function isValidationError(error: unknown): error is ValidationError;
190
+ /**
191
+ * Type guard to check if an error is a RateLimitError.
192
+ */
193
+ export declare function isRateLimitError(error: unknown): error is RateLimitError;
194
+ /**
195
+ * Type guard to check if an error is a NetworkError.
196
+ */
197
+ export declare function isNetworkError(error: unknown): error is NetworkError;
198
+ /**
199
+ * Type guard to check if an error is a TimeoutError.
200
+ */
201
+ export declare function isTimeoutError(error: unknown): error is TimeoutError;
202
+ /**
203
+ * Type guard to check if an error is a ServerError.
204
+ */
205
+ export declare function isServerError(error: unknown): error is ServerError;
206
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/errors/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @attrove/sdk
3
+ *
4
+ * Official TypeScript SDK for the Attrove API.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { Attrove } from '@attrove/sdk';
9
+ *
10
+ * // Create a client for end-user operations
11
+ * const attrove = new Attrove({
12
+ * apiKey: 'sk_...',
13
+ * userId: 'user-uuid'
14
+ * });
15
+ *
16
+ * // Query user's context
17
+ * const response = await attrove.query('What meetings do I have tomorrow?');
18
+ * console.log(response.answer);
19
+ *
20
+ * // Create an admin client for server-to-server operations
21
+ * const admin = Attrove.admin({
22
+ * clientId: 'your-client-id',
23
+ * clientSecret: 'your-client-secret'
24
+ * });
25
+ *
26
+ * // Create a user
27
+ * const { id, apiKey } = await admin.users.create({
28
+ * email: 'user@example.com'
29
+ * });
30
+ * ```
31
+ *
32
+ * @packageDocumentation
33
+ */
34
+ import { Attrove as AttroveClient } from './client';
35
+ import { AttroveAdmin } from './admin-client';
36
+ import { AttroveAdminConfig } from './types';
37
+ export declare class Attrove extends AttroveClient {
38
+ /**
39
+ * Create an admin client for server-to-server operations.
40
+ *
41
+ * @param config - Admin client configuration
42
+ * @returns Admin client instance
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const admin = Attrove.admin({
47
+ * clientId: 'your-client-id',
48
+ * clientSecret: 'your-client-secret'
49
+ * });
50
+ * ```
51
+ */
52
+ static admin(config: AttroveAdminConfig): AttroveAdmin;
53
+ }
54
+ export { AttroveAdmin } from './admin-client';
55
+ export type { AdminUsersResource } from './admin-client';
56
+ export * from './types';
57
+ export { AttroveError, AuthenticationError, AuthorizationError, NotFoundError, ValidationError, RateLimitError, NetworkError, TimeoutError, ServerError, isAttroveError, isAuthenticationError, isAuthorizationError, isNotFoundError, isValidationError, isRateLimitError, isNetworkError, isTimeoutError, isServerError, } from './errors';
58
+ export type { UserWithIntegrations, UpdateUserOptions, } from './resources/users';
59
+ export type { MessagesPage } from './resources/messages';
60
+ export type { ConversationsPage, ConversationSyncUpdate, } from './resources/conversations';
61
+ export { generateMessageId } from './utils/streaming';
62
+ export type { StreamOptions, StreamResult } from './utils/streaming';
63
+ export { SDK_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, } from './constants';
64
+ export { getVersion } from './version';
65
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/sdk/src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAG7C,qBAAa,OAAQ,SAAQ,aAAa;IACxC;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY;CAGvD;AAGD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGzD,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,aAAa,GACd,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EACV,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Conversations Resource
3
+ *
4
+ * Provides methods for accessing and managing conversations (channels, threads, etc.).
5
+ */
6
+ import { HttpClient } from '../utils/fetch';
7
+ import { Conversation, Pagination, ListConversationsOptions } from '../types';
8
+ /**
9
+ * Paginated conversations response.
10
+ */
11
+ export interface ConversationsPage {
12
+ data: Conversation[];
13
+ pagination: Pagination;
14
+ }
15
+ /**
16
+ * Conversation sync settings update.
17
+ */
18
+ export interface ConversationSyncUpdate {
19
+ id: string;
20
+ importMessages: boolean;
21
+ }
22
+ /**
23
+ * Conversations resource for accessing conversation data.
24
+ *
25
+ * Provides methods for listing conversations and managing sync settings.
26
+ */
27
+ export declare class ConversationsResource {
28
+ private readonly http;
29
+ private readonly userId;
30
+ constructor(http: HttpClient, userId: string);
31
+ /**
32
+ * List conversations with optional filtering.
33
+ *
34
+ * @param options - Filtering and pagination options
35
+ * @returns Paginated list of conversations
36
+ *
37
+ * @throws {AuthenticationError} If the API key is invalid or expired
38
+ * @throws {ValidationError} If the filter parameters are invalid
39
+ * @throws {NetworkError} If unable to reach the API
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * // List all conversations
44
+ * const { data, pagination } = await attrove.conversations.list();
45
+ *
46
+ * // List only synced conversations
47
+ * const { data } = await attrove.conversations.list({ syncedOnly: true });
48
+ *
49
+ * // Filter by integration
50
+ * const { data } = await attrove.conversations.list({
51
+ * integrationIds: ['550e8400-e29b-41d4-a716-446655440000']
52
+ * });
53
+ * ```
54
+ */
55
+ list(options?: ListConversationsOptions): Promise<ConversationsPage>;
56
+ /**
57
+ * Update sync settings for multiple conversations.
58
+ *
59
+ * @param updates - Array of conversation sync updates
60
+ * @returns Count of updated conversations
61
+ *
62
+ * @throws {AuthenticationError} If the API key is invalid or expired
63
+ * @throws {ValidationError} If the updates are invalid
64
+ * @throws {NotFoundError} If any conversation does not exist
65
+ * @throws {NetworkError} If unable to reach the API
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * // Enable syncing for specific conversations
70
+ * const { updated } = await attrove.conversations.updateSync([
71
+ * { id: '550e8400-e29b-41d4-a716-446655440000', importMessages: true },
72
+ * { id: '550e8400-e29b-41d4-a716-446655440001', importMessages: false }
73
+ * ]);
74
+ * console.log(`Updated ${updated} conversations`);
75
+ * ```
76
+ */
77
+ updateSync(updates: ConversationSyncUpdate[]): Promise<{
78
+ updated: number;
79
+ }>;
80
+ }
81
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/conversations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAqB,UAAU,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;;GAIG;AACH,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,IAAI,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IA4B9E;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,UAAU,CAAC,OAAO,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAalF"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Resource exports
3
+ */
4
+ export { UsersResource } from './users';
5
+ export type { UserWithIntegrations, UpdateUserOptions } from './users';
6
+ export { MessagesResource } from './messages';
7
+ export type { MessagesPage } from './messages';
8
+ export { ConversationsResource } from './conversations';
9
+ export type { ConversationsPage, ConversationSyncUpdate } from './conversations';
10
+ export { IntegrationsResource } from './integrations';
11
+ export { QueryResource } from './query';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}