@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,63 @@
1
+ /**
2
+ * Integrations Resource
3
+ *
4
+ * Provides methods for managing connected integrations (Gmail, Slack, etc.).
5
+ */
6
+ import { HttpClient } from '../utils/fetch';
7
+ import { Integration } from '../types';
8
+ /**
9
+ * Integrations resource for managing connected services.
10
+ *
11
+ * Provides methods for listing and disconnecting integrations
12
+ * (Gmail, Slack, Google Calendar, etc.).
13
+ */
14
+ export declare class IntegrationsResource {
15
+ private readonly http;
16
+ private readonly userId;
17
+ constructor(http: HttpClient, userId: string);
18
+ /**
19
+ * List all integrations for the user.
20
+ *
21
+ * Note: This returns the same data as `users.get().integrations`.
22
+ * Use this method when you only need integration data.
23
+ *
24
+ * @returns Array of connected integrations
25
+ *
26
+ * @throws {AuthenticationError} If the API key is invalid or expired
27
+ * @throws {NetworkError} If unable to reach the API
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * const integrations = await attrove.integrations.list();
32
+ * console.log(integrations.map(i => `${i.provider}: ${i.auth_status}`));
33
+ * ```
34
+ */
35
+ list(): Promise<Integration[]>;
36
+ /**
37
+ * Disconnect an integration.
38
+ *
39
+ * This will:
40
+ * - Revoke OAuth tokens where possible
41
+ * - Stop syncing data from this integration
42
+ * - Remove the integration record
43
+ *
44
+ * Note: Historical data that was already synced is retained.
45
+ *
46
+ * @param id - Integration ID (UUID format)
47
+ * @returns Confirmation of deletion
48
+ *
49
+ * @throws {AuthenticationError} If the API key is invalid or expired
50
+ * @throws {NotFoundError} If the integration does not exist
51
+ * @throws {NetworkError} If unable to reach the API
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const { deleted } = await attrove.integrations.disconnect('integration-uuid');
56
+ * console.log(deleted ? 'Disconnected' : 'Already removed');
57
+ * ```
58
+ */
59
+ disconnect(id: string): Promise<{
60
+ deleted: boolean;
61
+ }>;
62
+ }
63
+ //# sourceMappingURL=integrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/integrations.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;;;;;OAgBG;IACG,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAOpC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;CAK5D"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Messages Resource
3
+ *
4
+ * Provides methods for accessing messages from connected integrations.
5
+ */
6
+ import { HttpClient } from '../utils/fetch';
7
+ import { Message, Pagination, ListMessagesOptions } from '../types';
8
+ /**
9
+ * Paginated messages response.
10
+ */
11
+ export interface MessagesPage {
12
+ data: Message[];
13
+ pagination: Pagination;
14
+ }
15
+ /**
16
+ * Messages resource for accessing message data.
17
+ *
18
+ * Provides methods for listing and retrieving messages from
19
+ * connected integrations (Gmail, Slack, etc.).
20
+ */
21
+ export declare class MessagesResource {
22
+ private readonly http;
23
+ private readonly userId;
24
+ constructor(http: HttpClient, userId: string);
25
+ /**
26
+ * List messages with optional filtering.
27
+ *
28
+ * @param options - Filtering, pagination, and expansion options
29
+ * @returns Paginated list of messages
30
+ *
31
+ * @throws {AuthenticationError} If the API key is invalid or expired
32
+ * @throws {ValidationError} If the filter parameters are invalid
33
+ * @throws {NetworkError} If unable to reach the API
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * // List recent messages
38
+ * const { data, pagination } = await attrove.messages.list();
39
+ *
40
+ * // List messages with body text
41
+ * const { data } = await attrove.messages.list({ expand: ['body_text'] });
42
+ *
43
+ * // Fetch specific messages by ID (UUIDs)
44
+ * const { data } = await attrove.messages.list({
45
+ * ids: ['message-uuid-1', 'message-uuid-2'],
46
+ * expand: ['body_text']
47
+ * });
48
+ * ```
49
+ */
50
+ list(options?: ListMessagesOptions): Promise<MessagesPage>;
51
+ /**
52
+ * Get a single message by ID.
53
+ *
54
+ * @param id - Message ID (UUID format)
55
+ * @returns The requested message
56
+ *
57
+ * @throws {AuthenticationError} If the API key is invalid or expired
58
+ * @throws {NotFoundError} If the message does not exist
59
+ * @throws {NetworkError} If unable to reach the API
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const message = await attrove.messages.get('message-uuid');
64
+ * console.log(message.subject);
65
+ * ```
66
+ */
67
+ get(id: string): Promise<Message>;
68
+ }
69
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAqB,UAAU,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEvF;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;;;GAKG;AACH,qBAAa,gBAAgB;IAEzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,IAAI,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,YAAY,CAAC;IAwCpE;;;;;;;;;;;;;;;OAeG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAGxC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Query Resource
3
+ *
4
+ * Provides methods for RAG (Retrieval-Augmented Generation) queries.
5
+ */
6
+ import { HttpClient } from '../utils/fetch';
7
+ import { QueryOptions, QueryResponse, SearchOptions, SearchResponse } from '../types';
8
+ /**
9
+ * Query resource for RAG operations.
10
+ *
11
+ * Provides methods for AI-powered queries and semantic search
12
+ * across the user's unified context.
13
+ */
14
+ export declare class QueryResource {
15
+ private readonly http;
16
+ private readonly userId;
17
+ constructor(http: HttpClient, userId: string);
18
+ /**
19
+ * Query the user's unified context with AI.
20
+ *
21
+ * Performs semantic search across connected integrations and returns
22
+ * an AI-generated answer based on the relevant context.
23
+ *
24
+ * @param prompt - The natural language question to answer
25
+ * @param options - Query options including history, filters, etc.
26
+ * @returns AI-generated answer with conversation history and source references
27
+ *
28
+ * @throws {AuthenticationError} If the API key is invalid or expired
29
+ * @throws {ValidationError} If the query parameters are invalid
30
+ * @throws {RateLimitError} If rate limits are exceeded
31
+ * @throws {NetworkError} If unable to reach the API
32
+ * @throws {ServerError} If the server encounters an error during processing
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // Simple query
37
+ * const response = await attrove.query('What did Sarah say about the Q4 budget?');
38
+ *
39
+ * // With conversation history
40
+ * const response = await attrove.query('What about Q3?', {
41
+ * history: [
42
+ * { role: 'user', content: 'What did Sarah say about the Q4 budget?' },
43
+ * { role: 'assistant', content: 'Sarah mentioned...' }
44
+ * ]
45
+ * });
46
+ *
47
+ * // With filters
48
+ * const response = await attrove.query('Latest updates', {
49
+ * integrationIds: ['550e8400-e29b-41d4-a716-446655440000'],
50
+ * includeSources: true
51
+ * });
52
+ * ```
53
+ */
54
+ query(prompt: string, options?: QueryOptions): Promise<QueryResponse>;
55
+ /**
56
+ * Semantic search across the user's context.
57
+ *
58
+ * Returns raw matching messages grouped by conversation, without AI summarization.
59
+ * Use this when you need full control over how results are displayed.
60
+ *
61
+ * @param query - The search query (semantic, not keyword-based)
62
+ * @param options - Search options including filters, date range, etc.
63
+ * @returns Matching messages grouped by conversation
64
+ *
65
+ * @throws {AuthenticationError} If the API key is invalid or expired
66
+ * @throws {ValidationError} If the search parameters are invalid
67
+ * @throws {RateLimitError} If rate limits are exceeded
68
+ * @throws {NetworkError} If unable to reach the API
69
+ * @throws {ServerError} If the server encounters an error during search
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // Basic search
74
+ * const results = await attrove.search('product launch');
75
+ *
76
+ * // With filters
77
+ * const results = await attrove.search('budget discussion', {
78
+ * afterDate: '2024-01-01T00:00:00Z',
79
+ * senderDomains: ['acme.com'],
80
+ * includeBodyText: true
81
+ * });
82
+ * ```
83
+ */
84
+ search(query: string, options?: SearchOptions): Promise<SearchResponse>;
85
+ }
86
+ //# sourceMappingURL=query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/query.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAEf,MAAM,UAAU,CAAC;AAYlB;;;;;GAKG;AACH,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAmC/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,cAAc,CAAC;CAiClF"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Users Resource
3
+ *
4
+ * Provides methods for accessing user data and sync statistics.
5
+ */
6
+ import { HttpClient } from '../utils/fetch';
7
+ import { User, Integration, SyncStats } from '../types';
8
+ /**
9
+ * User with integrations response.
10
+ */
11
+ export interface UserWithIntegrations {
12
+ user: User;
13
+ integrations: Integration[];
14
+ }
15
+ /**
16
+ * User update options.
17
+ */
18
+ export interface UpdateUserOptions {
19
+ firstName?: string;
20
+ lastName?: string;
21
+ role?: string;
22
+ timezone?: string;
23
+ onboarded?: boolean;
24
+ }
25
+ /**
26
+ * Users resource for accessing user data.
27
+ *
28
+ * Provides methods for retrieving user profiles, updating settings,
29
+ * and accessing sync statistics across integrations.
30
+ */
31
+ export declare class UsersResource {
32
+ private readonly http;
33
+ private readonly userId;
34
+ constructor(http: HttpClient, userId: string);
35
+ /**
36
+ * Get the current user's profile and integrations.
37
+ *
38
+ * @returns User profile with connected integrations
39
+ *
40
+ * @throws {AuthenticationError} If the API key is invalid or expired
41
+ * @throws {NotFoundError} If the user does not exist
42
+ * @throws {NetworkError} If unable to reach the API
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const { user, integrations } = await attrove.users.get();
47
+ * console.log(`${user.email} has ${integrations.length} integrations`);
48
+ * ```
49
+ */
50
+ get(): Promise<UserWithIntegrations>;
51
+ /**
52
+ * Update the current user's profile.
53
+ *
54
+ * @param options - Fields to update
55
+ * @returns Updated user profile
56
+ *
57
+ * @throws {AuthenticationError} If the API key is invalid or expired
58
+ * @throws {ValidationError} If the update options are invalid
59
+ * @throws {NotFoundError} If the user does not exist
60
+ * @throws {NetworkError} If unable to reach the API
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const user = await attrove.users.update({
65
+ * timezone: 'America/New_York',
66
+ * firstName: 'John'
67
+ * });
68
+ * ```
69
+ */
70
+ update(options: UpdateUserOptions): Promise<User>;
71
+ /**
72
+ * Get sync statistics for the user's integrations.
73
+ *
74
+ * @returns Sync statistics including message counts and last sync times
75
+ *
76
+ * @throws {AuthenticationError} If the API key is invalid or expired
77
+ * @throws {NotFoundError} If the user does not exist
78
+ * @throws {NetworkError} If unable to reach the API
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const stats = await attrove.users.syncStats();
83
+ * console.log(`Total messages: ${stats.totals.messages.count}`);
84
+ * ```
85
+ */
86
+ syncStats(): Promise<SyncStats>;
87
+ }
88
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../../../../packages/sdk/src/resources/users.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IAEtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM;IAGjC;;;;;;;;;;;;;;OAcG;IACG,GAAG,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI1C;;;;;;;;;;;;;;;;;;OAkBG;IACG,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAYvD;;;;;;;;;;;;;;OAcG;IACG,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC;CAGtC"}