@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
package/cjs/README.md ADDED
@@ -0,0 +1,247 @@
1
+ # @attrove/sdk
2
+
3
+ Official TypeScript SDK for the Attrove API. Access AI-powered context from your users' Gmail, Slack, Google Calendar, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @attrove/sdk
9
+ # or
10
+ yarn add @attrove/sdk
11
+ # or
12
+ pnpm add @attrove/sdk
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { Attrove } from '@attrove/sdk';
19
+
20
+ // Create a client
21
+ const attrove = new Attrove({
22
+ apiKey: 'sk_...', // API key from your dashboard
23
+ userId: 'user-uuid' // User ID from provisioning
24
+ });
25
+
26
+ // Query user's context
27
+ const response = await attrove.query('What meetings do I have tomorrow?');
28
+ console.log(response.answer);
29
+
30
+ // Search for specific information
31
+ const results = await attrove.search('quarterly report');
32
+ ```
33
+
34
+ ## Core Methods
35
+
36
+ ### `query(prompt, options?)`
37
+
38
+ Ask questions about the user's unified context with AI-generated answers.
39
+
40
+ ```typescript
41
+ // Simple query
42
+ const response = await attrove.query('What did Sarah say about the Q4 budget?');
43
+ console.log(response.answer);
44
+
45
+ // Multi-turn conversation - pass history from previous response
46
+ let history = response.history;
47
+ const followUp = await attrove.query('What about Q3?', { history });
48
+ // Update history for subsequent queries
49
+ history = followUp.history;
50
+
51
+ // With filters
52
+ const filtered = await attrove.query('Latest updates', {
53
+ integrationIds: ['integration-uuid'], // Only search specific integration
54
+ includeSources: true // Include source snippets
55
+ });
56
+ ```
57
+
58
+ ### `search(query, options?)`
59
+
60
+ Semantic search that returns raw messages without AI summarization.
61
+
62
+ ```typescript
63
+ const results = await attrove.search('product launch', {
64
+ afterDate: '2024-01-01T00:00:00Z',
65
+ senderDomains: ['acme.com'],
66
+ includeBodyText: true
67
+ });
68
+
69
+ for (const [convId, conv] of Object.entries(results.conversations)) {
70
+ console.log(`Conversation: ${conv.conversation_name}`);
71
+ }
72
+ ```
73
+
74
+ ## Resource Namespaces
75
+
76
+ ### Users
77
+
78
+ ```typescript
79
+ // Get user profile and integrations
80
+ const { user, integrations } = await attrove.users.get();
81
+
82
+ // Update user profile
83
+ await attrove.users.update({
84
+ timezone: 'America/New_York'
85
+ });
86
+
87
+ // Get sync statistics
88
+ const stats = await attrove.users.syncStats();
89
+ console.log(`Messages: ${stats.totals.messages.count}`);
90
+ ```
91
+
92
+ ### Messages
93
+
94
+ ```typescript
95
+ // List messages
96
+ const { data, pagination } = await attrove.messages.list({
97
+ limit: 20,
98
+ expand: ['body_text']
99
+ });
100
+
101
+ // Get specific messages (e.g., after a query)
102
+ const { data: messages } = await attrove.messages.list({
103
+ ids: response.used_message_ids,
104
+ expand: ['body_text']
105
+ });
106
+
107
+ // Get a single message by ID
108
+ const message = await attrove.messages.get('message-uuid');
109
+ ```
110
+
111
+ ### Conversations
112
+
113
+ ```typescript
114
+ // List conversations
115
+ const { data: conversations } = await attrove.conversations.list({
116
+ syncedOnly: true
117
+ });
118
+
119
+ // Update sync settings
120
+ await attrove.conversations.updateSync([
121
+ { id: 'conversation-uuid-1', importMessages: true },
122
+ { id: 'conversation-uuid-2', importMessages: false }
123
+ ]);
124
+ ```
125
+
126
+ ### Integrations
127
+
128
+ ```typescript
129
+ // List integrations
130
+ const integrations = await attrove.integrations.list();
131
+
132
+ // Disconnect an integration
133
+ await attrove.integrations.disconnect('integration-uuid');
134
+ ```
135
+
136
+ ## Server-to-Server (Admin) API
137
+
138
+ Use the admin client for operations that require partner authentication:
139
+
140
+ ```typescript
141
+ import { Attrove } from '@attrove/sdk';
142
+
143
+ // Create admin client
144
+ const admin = Attrove.admin({
145
+ clientId: 'your-client-id',
146
+ clientSecret: 'your-client-secret'
147
+ });
148
+
149
+ // Create a user
150
+ const { id, apiKey } = await admin.users.create({
151
+ email: 'user@example.com',
152
+ firstName: 'John',
153
+ lastName: 'Doe'
154
+ });
155
+
156
+ // Generate integration token for OAuth flow
157
+ const { token: connectToken, expires_at } = await admin.users.createConnectToken(id);
158
+
159
+ // Use the apiKey for subsequent API calls
160
+ const attrove = new Attrove({ apiKey, userId: id });
161
+
162
+ // Redirect user to OAuth flow
163
+ // The URL format depends on your deployment - check your dashboard for the exact URL
164
+ // Example: const oauthUrl = `${YOUR_BASE_URL}/connect/gmail?token=${connectToken}`;
165
+ ```
166
+
167
+ ## Error Handling
168
+
169
+ The SDK provides typed errors for better error handling:
170
+
171
+ ```typescript
172
+ import {
173
+ Attrove,
174
+ AttroveError,
175
+ AuthenticationError,
176
+ NotFoundError,
177
+ RateLimitError
178
+ } from '@attrove/sdk';
179
+
180
+ try {
181
+ const response = await attrove.query('...');
182
+ } catch (error) {
183
+ if (error instanceof AuthenticationError) {
184
+ console.log('Invalid API key');
185
+ } else if (error instanceof RateLimitError) {
186
+ console.log(`Rate limited. Retry after ${error.retryAfter}s`);
187
+ } else if (error instanceof NotFoundError) {
188
+ console.log('Resource not found');
189
+ } else if (error instanceof AttroveError) {
190
+ console.log(`Error: ${error.code} - ${error.message}`);
191
+ }
192
+ }
193
+ ```
194
+
195
+ ## Streaming (Advanced)
196
+
197
+ For real-time streaming of query responses:
198
+
199
+ ```typescript
200
+ const result = await attrove.stream('What happened in the meeting?', {
201
+ onChunk: (chunk) => process.stdout.write(chunk),
202
+ onState: (state) => console.log('State:', state),
203
+ onEnd: (reason) => console.log('Stream ended:', reason)
204
+ });
205
+
206
+ console.log('Full answer:', result.answer);
207
+ ```
208
+
209
+ > **Note:** Streaming uses WebSocket connections and requires the same API key authentication as other SDK methods. It is primarily intended for end-user facing applications where progressive display of responses improves the user experience.
210
+
211
+ ## Configuration
212
+
213
+ ```typescript
214
+ const attrove = new Attrove({
215
+ apiKey: 'sk_...', // Required: API key
216
+ userId: 'user-uuid', // Required: User ID
217
+ baseUrl: 'https://api.attrove.com', // Optional: API base URL
218
+ timeout: 30000, // Optional: Request timeout (ms)
219
+ maxRetries: 3 // Optional: Retry attempts
220
+ });
221
+ ```
222
+
223
+ ## TypeScript Support
224
+
225
+ The SDK is fully typed. Import types as needed:
226
+
227
+ ```typescript
228
+ import {
229
+ QueryOptions,
230
+ QueryResponse,
231
+ SearchOptions,
232
+ SearchResponse,
233
+ User,
234
+ Message,
235
+ Integration,
236
+ ConversationMessage
237
+ } from '@attrove/sdk';
238
+ ```
239
+
240
+ ## Requirements
241
+
242
+ - Node.js 18.0.0 or later
243
+ - TypeScript 4.7+ (if using TypeScript)
244
+
245
+ ## License
246
+
247
+ MIT
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@attrove/sdk",
3
+ "version": "0.1.4",
4
+ "description": "Official TypeScript SDK for the Attrove API - AI-powered context retrieval for your apps",
5
+ "main": "./src/index.ts",
6
+ "module": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.ts",
11
+ "import": "./src/index.ts",
12
+ "require": "./src/index.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "sideEffects": false,
20
+ "keywords": [
21
+ "attrove",
22
+ "sdk",
23
+ "api",
24
+ "ai",
25
+ "rag",
26
+ "retrieval-augmented-generation",
27
+ "context",
28
+ "llm"
29
+ ],
30
+ "author": "Attrove <support@attrove.com>",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/attrove/attrove-js.git",
35
+ "directory": "packages/sdk"
36
+ },
37
+ "homepage": "https://docs.attrove.com",
38
+ "bugs": {
39
+ "url": "https://github.com/attrove/attrove-js/issues"
40
+ },
41
+ "engines": {
42
+ "node": ">=18.0.0"
43
+ },
44
+ "scripts": {
45
+ "build": "nx build sdk",
46
+ "test": "nx test sdk"
47
+ },
48
+ "devDependencies": {
49
+ "@types/node": "^20.0.0",
50
+ "typescript": "~5.7.0"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "type": "commonjs"
56
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Mock version module for Jest tests.
4
+ *
5
+ * This avoids the import.meta.url ESM issue when running tests with ts-jest.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.resetVersionCache = exports.getVersion = void 0;
9
+ function getVersion() {
10
+ return '1.0.0-test';
11
+ }
12
+ exports.getVersion = getVersion;
13
+ function resetVersionCache() {
14
+ // No-op in mock
15
+ }
16
+ exports.resetVersionCache = resetVersionCache;
17
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../../../packages/sdk/src/__mocks__/version.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,SAAgB,UAAU;IACxB,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,gCAEC;AAED,SAAgB,iBAAiB;IAC/B,gBAAgB;AAClB,CAAC;AAFD,8CAEC"}
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ /**
3
+ * Attrove Admin Client
4
+ *
5
+ * Server-to-server client for partner operations like user provisioning
6
+ * and integration token generation.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AttroveAdmin = exports.AdminUsersResource = void 0;
10
+ const fetch_1 = require("./utils/fetch");
11
+ const errors_1 = require("./errors");
12
+ const types_1 = require("./types");
13
+ const types_2 = require("./types");
14
+ const constants_1 = require("./constants");
15
+ /**
16
+ * Validate the admin client configuration.
17
+ *
18
+ * @throws {ValidationError} If the configuration is invalid
19
+ */
20
+ function validateAdminConfig(config) {
21
+ // Validate clientId
22
+ if (!config.clientId || typeof config.clientId !== 'string') {
23
+ throw new errors_1.ValidationError('clientId is required and must be a non-empty string', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'clientId' });
24
+ }
25
+ // Validate clientSecret
26
+ if (!config.clientSecret || typeof config.clientSecret !== 'string') {
27
+ throw new errors_1.ValidationError('clientSecret is required and must be a non-empty string', types_1.ErrorCodes.VALIDATION_REQUIRED_FIELD, { field: 'clientSecret' });
28
+ }
29
+ // Validate optional fields
30
+ if (config.timeout !== undefined && (typeof config.timeout !== 'number' || config.timeout <= 0)) {
31
+ throw new errors_1.ValidationError('timeout must be a positive number in milliseconds', types_1.ErrorCodes.VALIDATION_OUT_OF_RANGE, { field: 'timeout', value: config.timeout });
32
+ }
33
+ if (config.maxRetries !== undefined && (typeof config.maxRetries !== 'number' || config.maxRetries < 0)) {
34
+ throw new errors_1.ValidationError('maxRetries must be a non-negative number', types_1.ErrorCodes.VALIDATION_OUT_OF_RANGE, { field: 'maxRetries', value: config.maxRetries });
35
+ }
36
+ }
37
+ /**
38
+ * Users admin resource for managing users.
39
+ *
40
+ * Provides methods for creating users, generating integration tokens,
41
+ * and managing user data.
42
+ */
43
+ class AdminUsersResource {
44
+ constructor(http, clientId) {
45
+ this.http = http;
46
+ this.clientId = clientId;
47
+ }
48
+ /**
49
+ * Create or retrieve a user.
50
+ *
51
+ * Creates a new user by email, or retrieves an existing user if one exists.
52
+ * Returns an API key (sk_) for authenticating requests on behalf of this user.
53
+ *
54
+ * @param options - User creation options
55
+ * @returns User ID and API key
56
+ *
57
+ * @throws {ValidationError} If the email is invalid
58
+ * @throws {AuthenticationError} If partner credentials are invalid
59
+ * @throws {RateLimitError} If rate limits are exceeded
60
+ * @throws {NetworkError} If unable to reach the API
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const admin = Attrove.admin({ clientId, clientSecret });
65
+ *
66
+ * const { id, apiKey } = await admin.users.create({
67
+ * email: 'user@example.com',
68
+ * firstName: 'John',
69
+ * lastName: 'Doe'
70
+ * });
71
+ *
72
+ * // Use the apiKey to make API calls on behalf of this user
73
+ * const attrove = new Attrove({ apiKey, userId: id });
74
+ * ```
75
+ */
76
+ async create(options) {
77
+ const body = {
78
+ email: options.email,
79
+ client_id: this.clientId,
80
+ };
81
+ if (options.firstName)
82
+ body.first_name = options.firstName;
83
+ if (options.lastName)
84
+ body.last_name = options.lastName;
85
+ if (options.role)
86
+ body.role = options.role;
87
+ // API returns { id, token } but we rename to { id, apiKey } for clarity
88
+ // Route: POST /v1/users with X-Auth-Type: partner header
89
+ const response = await this.http.post('/v1/users', body);
90
+ return {
91
+ id: response.id,
92
+ apiKey: response.token,
93
+ };
94
+ }
95
+ /**
96
+ * Create an integration token for a user.
97
+ *
98
+ * Generates a short-lived token (pit_) for initiating OAuth flows.
99
+ * Use this token to redirect end-users to connect their integrations.
100
+ *
101
+ * @param userId - User ID (UUID format)
102
+ * @returns Integration token and expiration time
103
+ *
104
+ * @throws {ValidationError} If the userId is not a valid UUID
105
+ * @throws {AuthenticationError} If partner credentials are invalid
106
+ * @throws {NotFoundError} If the user doesn't exist
107
+ * @throws {RateLimitError} If rate limits are exceeded
108
+ * @throws {NetworkError} If unable to reach the API
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * const admin = Attrove.admin({ clientId, clientSecret });
113
+ *
114
+ * const { token, expires_at } = await admin.users.createConnectToken(userId);
115
+ *
116
+ * // Redirect user to OAuth flow with this token
117
+ * const oauthUrl = `https://connect.attrove.com/oauth/gmail?token=${token}`;
118
+ * ```
119
+ */
120
+ async createConnectToken(userId) {
121
+ // Validate userId format
122
+ if (!(0, types_2.isValidUUID)(userId)) {
123
+ throw new errors_1.ValidationError('userId must be a valid UUID format', types_1.ErrorCodes.VALIDATION_INVALID_FORMAT, { field: 'userId', expected: 'UUID format' });
124
+ }
125
+ const body = {
126
+ client_id: this.clientId,
127
+ };
128
+ // Route: POST /v1/users/:user_id/tokens with X-Auth-Type: partner header
129
+ return this.http.post(`/v1/users/${userId}/tokens`, body);
130
+ }
131
+ /**
132
+ * Delete a user.
133
+ *
134
+ * Permanently deletes a user and all associated data.
135
+ *
136
+ * @experimental This method is not yet implemented and will throw an error.
137
+ *
138
+ * @param userId - User ID (UUID format)
139
+ *
140
+ * @throws {Error} Always throws - not yet implemented
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * // Not yet available
145
+ * const admin = Attrove.admin({ clientId, clientSecret });
146
+ * await admin.users.delete(userId);
147
+ * ```
148
+ */
149
+ async delete(userId) {
150
+ // TODO: Implement user deletion endpoint
151
+ throw new Error('User deletion not yet implemented. This feature is coming soon.');
152
+ }
153
+ }
154
+ exports.AdminUsersResource = AdminUsersResource;
155
+ /**
156
+ * Admin client for server-to-server operations.
157
+ *
158
+ * Use this client for operations that require partner authentication:
159
+ * - Creating users
160
+ * - Generating integration tokens
161
+ * - Managing user data
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * import { Attrove } from '@attrove/sdk';
166
+ *
167
+ * const admin = Attrove.admin({
168
+ * clientId: 'your-client-id',
169
+ * clientSecret: 'your-client-secret'
170
+ * });
171
+ *
172
+ * // Create a user
173
+ * const { id, apiKey } = await admin.users.create({
174
+ * email: 'user@example.com'
175
+ * });
176
+ *
177
+ * // Generate an integration token
178
+ * const { token: connectToken } = await admin.users.createConnectToken(id);
179
+ * ```
180
+ */
181
+ class AttroveAdmin {
182
+ /**
183
+ * Create a new admin client.
184
+ *
185
+ * @param config - Admin client configuration
186
+ * @throws {ValidationError} If the configuration is invalid (missing clientId, clientSecret, etc.)
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * const admin = new AttroveAdmin({
191
+ * clientId: 'your-client-id',
192
+ * clientSecret: 'your-client-secret',
193
+ * timeout: 60000 // 60 seconds
194
+ * });
195
+ * ```
196
+ */
197
+ constructor(config) {
198
+ // Validate configuration before proceeding
199
+ validateAdminConfig(config);
200
+ this.config = {
201
+ clientId: config.clientId,
202
+ clientSecret: config.clientSecret,
203
+ baseUrl: config.baseUrl ?? constants_1.DEFAULT_BASE_URL,
204
+ timeout: config.timeout ?? constants_1.DEFAULT_TIMEOUT,
205
+ maxRetries: config.maxRetries ?? constants_1.DEFAULT_MAX_RETRIES,
206
+ onRetry: config.onRetry,
207
+ };
208
+ this.http = new fetch_1.HttpClient({
209
+ baseUrl: this.config.baseUrl,
210
+ clientId: this.config.clientId,
211
+ clientSecret: this.config.clientSecret,
212
+ timeout: this.config.timeout,
213
+ maxRetries: this.config.maxRetries,
214
+ onRetry: this.config.onRetry,
215
+ });
216
+ // Initialize resources
217
+ this.users = new AdminUsersResource(this.http, this.config.clientId);
218
+ }
219
+ }
220
+ exports.AttroveAdmin = AttroveAdmin;
221
+ //# sourceMappingURL=admin-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-client.js","sourceRoot":"","sources":["../../../../../packages/sdk/src/admin-client.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,yCAA2C;AAC3C,qCAA2C;AAC3C,mCAAqC;AACrC,mCAMiB;AACjB,2CAAqF;AAErF;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,MAA0B;IACrD,oBAAoB;IACpB,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC5D,MAAM,IAAI,wBAAe,CACvB,qDAA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