@doany-ai/sdk 0.1.0 → 0.2.1
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/dist/client.d.ts +28 -28
- package/dist/client.js +45 -37
- package/dist/client.types.d.ts +11 -11
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/modules/agents.types.d.ts +12 -12
- package/dist/modules/ai-gateway.types.d.ts +12 -12
- package/dist/modules/analytics.d.ts +1 -1
- package/dist/modules/analytics.js +1 -1
- package/dist/modules/analytics.types.d.ts +4 -4
- package/dist/modules/app-logs.d.ts +1 -1
- package/dist/modules/app-logs.js +1 -1
- package/dist/modules/app-logs.types.d.ts +3 -3
- package/dist/modules/auth.d.ts +1 -1
- package/dist/modules/auth.js +4 -4
- package/dist/modules/auth.types.d.ts +32 -32
- package/dist/modules/connectors.d.ts +1 -1
- package/dist/modules/connectors.js +1 -1
- package/dist/modules/connectors.types.d.ts +18 -18
- package/dist/modules/custom-integrations.d.ts +1 -1
- package/dist/modules/custom-integrations.js +1 -1
- package/dist/modules/custom-integrations.types.d.ts +5 -5
- package/dist/modules/entities.d.ts +1 -1
- package/dist/modules/entities.js +4 -4
- package/dist/modules/entities.types.d.ts +36 -36
- package/dist/modules/functions.d.ts +1 -1
- package/dist/modules/functions.js +1 -1
- package/dist/modules/functions.types.d.ts +8 -8
- package/dist/modules/integrations.d.ts +1 -1
- package/dist/modules/integrations.js +1 -1
- package/dist/modules/integrations.types.d.ts +27 -27
- package/dist/modules/sso.d.ts +1 -1
- package/dist/modules/sso.js +1 -1
- package/dist/modules/sso.types.d.ts +7 -7
- package/dist/modules/users.d.ts +1 -1
- package/dist/modules/users.js +1 -1
- package/dist/types.d.ts +5 -5
- package/dist/utils/auth-utils.d.ts +7 -7
- package/dist/utils/auth-utils.js +10 -10
- package/dist/utils/auth-utils.types.d.ts +7 -7
- package/dist/utils/axios-client.d.ts +10 -10
- package/dist/utils/axios-client.js +14 -14
- package/dist/utils/axios-client.types.d.ts +4 -4
- package/dist/utils/sharedInstance.js +6 -6
- package/dist/utils/socket-utils.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { AppLogsModule } from "./app-logs.types";
|
|
3
3
|
/**
|
|
4
|
-
* Creates the app logs module for the
|
|
4
|
+
* Creates the app logs module for the Doany SDK.
|
|
5
5
|
*
|
|
6
6
|
* @param axios - Axios instance
|
|
7
7
|
* @param appId - Application ID
|
package/dist/modules/app-logs.js
CHANGED
|
@@ -21,9 +21,9 @@ export interface AppLogsModule {
|
|
|
21
21
|
* @example
|
|
22
22
|
* ```typescript
|
|
23
23
|
* // Log page visit or feature usage
|
|
24
|
-
* await
|
|
25
|
-
* await
|
|
26
|
-
* await
|
|
24
|
+
* await doany.appLogs.logUserInApp('home');
|
|
25
|
+
* await doany.appLogs.logUserInApp('features-section');
|
|
26
|
+
* await doany.appLogs.logUserInApp('button-click');
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
logUserInApp(pageName: string): Promise<void>;
|
package/dist/modules/auth.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { AuthModule, AuthModuleOptions } from "./auth.types";
|
|
3
3
|
/**
|
|
4
|
-
* Creates the auth module for the
|
|
4
|
+
* Creates the auth module for the Doany SDK.
|
|
5
5
|
*
|
|
6
6
|
* @param axios - Axios instance for API requests
|
|
7
7
|
* @param functionsAxiosClient - Axios instance for functions API requests
|
package/dist/modules/auth.js
CHANGED
|
@@ -18,7 +18,7 @@ function loginViaPopup(url, redirectUrl, expectedOrigin) {
|
|
|
18
18
|
const height = 600;
|
|
19
19
|
const left = Math.round(window.screenX + (window.outerWidth - width) / 2);
|
|
20
20
|
const top = Math.round(window.screenY + (window.outerHeight - height) / 2);
|
|
21
|
-
const popup = window.open(url, "
|
|
21
|
+
const popup = window.open(url, "doany_auth", `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`);
|
|
22
22
|
if (!popup) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
@@ -53,7 +53,7 @@ function loginViaPopup(url, redirectUrl, expectedOrigin) {
|
|
|
53
53
|
window.addEventListener("message", onMessage);
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* Creates the auth module for the
|
|
56
|
+
* Creates the auth module for the Doany SDK.
|
|
57
57
|
*
|
|
58
58
|
* @param axios - Axios instance for API requests
|
|
59
59
|
* @param functionsAxiosClient - Axios instance for functions API requests
|
|
@@ -121,7 +121,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
121
121
|
// Remove token from localStorage
|
|
122
122
|
if (window.localStorage) {
|
|
123
123
|
try {
|
|
124
|
-
window.localStorage.removeItem("
|
|
124
|
+
window.localStorage.removeItem("doany_access_token");
|
|
125
125
|
// Remove "token" that is set by the built-in SDK of platform version 2
|
|
126
126
|
window.localStorage.removeItem("token");
|
|
127
127
|
}
|
|
@@ -148,7 +148,7 @@ export function createAuthModule(axios, functionsAxiosClient, appId, options) {
|
|
|
148
148
|
typeof window !== "undefined" &&
|
|
149
149
|
window.localStorage) {
|
|
150
150
|
try {
|
|
151
|
-
window.localStorage.setItem("
|
|
151
|
+
window.localStorage.setItem("doany_access_token", token);
|
|
152
152
|
// Set "token" that is set by the built-in SDK of platform version 2
|
|
153
153
|
window.localStorage.setItem("token", token);
|
|
154
154
|
}
|
|
@@ -52,7 +52,7 @@ export interface RegisterParams {
|
|
|
52
52
|
password: string;
|
|
53
53
|
/** Optional {@link https://developers.cloudflare.com/turnstile/ | Cloudflare Turnstile CAPTCHA token} for bot protection. */
|
|
54
54
|
turnstile_token?: string | null;
|
|
55
|
-
/** Optional {@link https://docs.
|
|
55
|
+
/** Optional {@link https://docs.doany.com/Getting-Started/Referral-program | referral code} from an existing user. */
|
|
56
56
|
referral_code?: string | null;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
@@ -108,7 +108,7 @@ export interface AuthModuleOptions {
|
|
|
108
108
|
*
|
|
109
109
|
* ## Authentication Modes
|
|
110
110
|
*
|
|
111
|
-
* The auth module is only available in user authentication mode (`
|
|
111
|
+
* The auth module is only available in user authentication mode (`doany.auth`).
|
|
112
112
|
*/
|
|
113
113
|
export interface AuthModule {
|
|
114
114
|
/**
|
|
@@ -119,7 +119,7 @@ export interface AuthModule {
|
|
|
119
119
|
* @example
|
|
120
120
|
* ```typescript
|
|
121
121
|
* // Get current user information
|
|
122
|
-
* const user = await
|
|
122
|
+
* const user = await doany.auth.me();
|
|
123
123
|
* console.log(`Logged in as: ${user.email}`);
|
|
124
124
|
* console.log(`User ID: ${user.id}`);
|
|
125
125
|
* ```
|
|
@@ -142,7 +142,7 @@ export interface AuthModule {
|
|
|
142
142
|
* @example
|
|
143
143
|
* ```typescript
|
|
144
144
|
* // Update role and custom fields defined in your User entity
|
|
145
|
-
* await
|
|
145
|
+
* await doany.auth.updateMe({
|
|
146
146
|
* role: 'admin',
|
|
147
147
|
* bio: 'Software developer',
|
|
148
148
|
* preferences: { theme: 'dark' }
|
|
@@ -161,13 +161,13 @@ export interface AuthModule {
|
|
|
161
161
|
* @example
|
|
162
162
|
* ```typescript
|
|
163
163
|
* // Redirect to login and come back to current page
|
|
164
|
-
*
|
|
164
|
+
* doany.auth.redirectToLogin(window.location.href);
|
|
165
165
|
* ```
|
|
166
166
|
*
|
|
167
167
|
* @example
|
|
168
168
|
* ```typescript
|
|
169
169
|
* // Redirect to login and then go to the dashboard page
|
|
170
|
-
*
|
|
170
|
+
* doany.auth.redirectToLogin('/dashboard');
|
|
171
171
|
* ```
|
|
172
172
|
*/
|
|
173
173
|
redirectToLogin(nextUrl: string): void;
|
|
@@ -181,7 +181,7 @@ export interface AuthModule {
|
|
|
181
181
|
* - `'microsoft'`: {@link https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow | Microsoft OAuth}. Enable Microsoft in your app's authentication settings before specifying this provider.
|
|
182
182
|
* - `'facebook'`: {@link https://developers.facebook.com/docs/facebook-login | Facebook Login}. Enable Facebook in your app's authentication settings before using.
|
|
183
183
|
* - `'apple'`: {@link https://developer.apple.com/sign-in-with-apple/ | Sign in with Apple}. Enable Apple in your app's authentication settings before using this provider.
|
|
184
|
-
* - `'sso'`: Enterprise SSO. {@link https://docs.
|
|
184
|
+
* - `'sso'`: Enterprise SSO. {@link https://docs.doany.com/Setting-up-your-app/Setting-up-SSO | Set up an SSO provider} in your app's authentication settings before using this provider.
|
|
185
185
|
*
|
|
186
186
|
* @param provider - The authentication provider to use: `'google'`, `'microsoft'`, `'facebook'`, `'apple'`, or `'sso'`.
|
|
187
187
|
* @param fromUrl - URL to redirect to after successful authentication. Defaults to `'/'`.
|
|
@@ -189,25 +189,25 @@ export interface AuthModule {
|
|
|
189
189
|
* @example
|
|
190
190
|
* ```typescript
|
|
191
191
|
* // Google
|
|
192
|
-
*
|
|
192
|
+
* doany.auth.loginWithProvider('google', window.location.pathname);
|
|
193
193
|
* ```
|
|
194
194
|
*
|
|
195
195
|
* @example
|
|
196
196
|
* ```typescript
|
|
197
197
|
* // Microsoft
|
|
198
|
-
*
|
|
198
|
+
* doany.auth.loginWithProvider('microsoft', '/dashboard');
|
|
199
199
|
* ```
|
|
200
200
|
*
|
|
201
201
|
* @example
|
|
202
202
|
* ```typescript
|
|
203
203
|
* // Apple
|
|
204
|
-
*
|
|
204
|
+
* doany.auth.loginWithProvider('apple', '/dashboard');
|
|
205
205
|
* ```
|
|
206
206
|
*
|
|
207
207
|
* @example
|
|
208
208
|
* ```typescript
|
|
209
209
|
* // SSO
|
|
210
|
-
*
|
|
210
|
+
* doany.auth.loginWithProvider('sso', '/dashboard');
|
|
211
211
|
* ```
|
|
212
212
|
*
|
|
213
213
|
*/
|
|
@@ -222,19 +222,19 @@ export interface AuthModule {
|
|
|
222
222
|
* @example
|
|
223
223
|
* ```typescript
|
|
224
224
|
* // Logout and reload page
|
|
225
|
-
*
|
|
225
|
+
* doany.auth.logout();
|
|
226
226
|
* ```
|
|
227
227
|
*
|
|
228
228
|
* @example
|
|
229
229
|
* ```typescript
|
|
230
230
|
* // Logout and redirect to login page
|
|
231
|
-
*
|
|
231
|
+
* doany.auth.logout('/login');
|
|
232
232
|
* ```
|
|
233
233
|
*
|
|
234
234
|
* @example
|
|
235
235
|
* ```typescript
|
|
236
236
|
* // Logout and redirect to home
|
|
237
|
-
*
|
|
237
|
+
* doany.auth.logout('/');
|
|
238
238
|
* ```
|
|
239
239
|
*/
|
|
240
240
|
logout(redirectUrl?: string): void;
|
|
@@ -249,13 +249,13 @@ export interface AuthModule {
|
|
|
249
249
|
* @example
|
|
250
250
|
* ```typescript
|
|
251
251
|
* // Set token and save to local storage
|
|
252
|
-
*
|
|
252
|
+
* doany.auth.setToken('eyJhbGciOiJIUzI1NiIs...');
|
|
253
253
|
* ```
|
|
254
254
|
*
|
|
255
255
|
* @example
|
|
256
256
|
* ```typescript
|
|
257
257
|
* // Set token without saving to local storage
|
|
258
|
-
*
|
|
258
|
+
* doany.auth.setToken('eyJhbGciOiJIUzI1NiIs...', false);
|
|
259
259
|
* ```
|
|
260
260
|
*/
|
|
261
261
|
setToken(token: string, saveToStorage?: boolean): void;
|
|
@@ -274,7 +274,7 @@ export interface AuthModule {
|
|
|
274
274
|
* ```typescript
|
|
275
275
|
* // Login with email and password
|
|
276
276
|
* try {
|
|
277
|
-
* const { access_token, user } = await
|
|
277
|
+
* const { access_token, user } = await doany.auth.loginViaEmailPassword(
|
|
278
278
|
* 'user@example.com',
|
|
279
279
|
* 'securePassword123'
|
|
280
280
|
* );
|
|
@@ -287,7 +287,7 @@ export interface AuthModule {
|
|
|
287
287
|
* @example
|
|
288
288
|
* ```typescript
|
|
289
289
|
* // With captcha token
|
|
290
|
-
* const response = await
|
|
290
|
+
* const response = await doany.auth.loginViaEmailPassword(
|
|
291
291
|
* 'user@example.com',
|
|
292
292
|
* 'securePassword123',
|
|
293
293
|
* 'captcha-token-here'
|
|
@@ -303,12 +303,12 @@ export interface AuthModule {
|
|
|
303
303
|
* @example
|
|
304
304
|
* ```typescript
|
|
305
305
|
* // Check authentication status
|
|
306
|
-
* const isAuthenticated = await
|
|
306
|
+
* const isAuthenticated = await doany.auth.isAuthenticated();
|
|
307
307
|
* if (isAuthenticated) {
|
|
308
308
|
* console.log('User is logged in');
|
|
309
309
|
* } else {
|
|
310
310
|
* // Redirect to login page
|
|
311
|
-
*
|
|
311
|
+
* doany.auth.redirectToLogin(window.location.href);
|
|
312
312
|
* }
|
|
313
313
|
* ```
|
|
314
314
|
*/
|
|
@@ -327,7 +327,7 @@ export interface AuthModule {
|
|
|
327
327
|
* @example
|
|
328
328
|
* ```typescript
|
|
329
329
|
* try {
|
|
330
|
-
* await
|
|
330
|
+
* await doany.auth.inviteUser('newuser@example.com', 'user');
|
|
331
331
|
* console.log('Invitation sent successfully!');
|
|
332
332
|
* } catch (error) {
|
|
333
333
|
* console.error('Failed to send invitation:', error);
|
|
@@ -349,20 +349,20 @@ export interface AuthModule {
|
|
|
349
349
|
* @example
|
|
350
350
|
* ```typescript
|
|
351
351
|
* // Register a new user
|
|
352
|
-
* await
|
|
352
|
+
* await doany.auth.register({
|
|
353
353
|
* email: 'newuser@example.com',
|
|
354
354
|
* password: 'securePassword123',
|
|
355
355
|
* referral_code: 'FRIEND2024'
|
|
356
356
|
* });
|
|
357
357
|
*
|
|
358
358
|
* // Verify with the OTP code from the user's email
|
|
359
|
-
* await
|
|
359
|
+
* await doany.auth.verifyOtp({
|
|
360
360
|
* email: 'newuser@example.com',
|
|
361
361
|
* otpCode: '123456'
|
|
362
362
|
* });
|
|
363
363
|
*
|
|
364
364
|
* // Log the user in after verification
|
|
365
|
-
* const { access_token, user } = await
|
|
365
|
+
* const { access_token, user } = await doany.auth.loginViaEmailPassword(
|
|
366
366
|
* 'newuser@example.com',
|
|
367
367
|
* 'securePassword123'
|
|
368
368
|
* );
|
|
@@ -388,7 +388,7 @@ export interface AuthModule {
|
|
|
388
388
|
* ```typescript
|
|
389
389
|
* // Verify the code the user entered from their email
|
|
390
390
|
* try {
|
|
391
|
-
* await
|
|
391
|
+
* await doany.auth.verifyOtp({
|
|
392
392
|
* email: 'user@example.com',
|
|
393
393
|
* otpCode: '123456'
|
|
394
394
|
* });
|
|
@@ -401,19 +401,19 @@ export interface AuthModule {
|
|
|
401
401
|
* @example
|
|
402
402
|
* ```typescript
|
|
403
403
|
* // Full registration flow
|
|
404
|
-
* await
|
|
404
|
+
* await doany.auth.register({
|
|
405
405
|
* email: 'newuser@example.com',
|
|
406
406
|
* password: 'securePassword123'
|
|
407
407
|
* });
|
|
408
408
|
*
|
|
409
409
|
* // The user receives an OTP code by email. Collect it and verify.
|
|
410
|
-
* await
|
|
410
|
+
* await doany.auth.verifyOtp({
|
|
411
411
|
* email: 'newuser@example.com',
|
|
412
412
|
* otpCode: '123456'
|
|
413
413
|
* });
|
|
414
414
|
*
|
|
415
415
|
* // Log the user in after verification
|
|
416
|
-
* const { access_token, user } = await
|
|
416
|
+
* const { access_token, user } = await doany.auth.loginViaEmailPassword(
|
|
417
417
|
* 'newuser@example.com',
|
|
418
418
|
* 'securePassword123'
|
|
419
419
|
* );
|
|
@@ -437,7 +437,7 @@ export interface AuthModule {
|
|
|
437
437
|
* ```typescript
|
|
438
438
|
* // Resend the OTP when the user didn't receive the original
|
|
439
439
|
* try {
|
|
440
|
-
* await
|
|
440
|
+
* await doany.auth.resendOtp('user@example.com');
|
|
441
441
|
* console.log('OTP resent! Please check your email.');
|
|
442
442
|
* } catch (error) {
|
|
443
443
|
* console.error('Failed to resend OTP:', error);
|
|
@@ -457,7 +457,7 @@ export interface AuthModule {
|
|
|
457
457
|
* @example
|
|
458
458
|
* ```typescript
|
|
459
459
|
* try {
|
|
460
|
-
* await
|
|
460
|
+
* await doany.auth.resetPasswordRequest('user@example.com');
|
|
461
461
|
* console.log('Password reset email sent!');
|
|
462
462
|
* } catch (error) {
|
|
463
463
|
* console.error('Failed to send password reset email:', error);
|
|
@@ -478,7 +478,7 @@ export interface AuthModule {
|
|
|
478
478
|
* @example
|
|
479
479
|
* ```typescript
|
|
480
480
|
* try {
|
|
481
|
-
* await
|
|
481
|
+
* await doany.auth.resetPassword({
|
|
482
482
|
* resetToken: 'token-from-email',
|
|
483
483
|
* newPassword: 'newSecurePassword456'
|
|
484
484
|
* });
|
|
@@ -502,7 +502,7 @@ export interface AuthModule {
|
|
|
502
502
|
* @example
|
|
503
503
|
* ```typescript
|
|
504
504
|
* try {
|
|
505
|
-
* await
|
|
505
|
+
* await doany.auth.changePassword({
|
|
506
506
|
* userId: 'user-123',
|
|
507
507
|
* currentPassword: 'oldPassword123',
|
|
508
508
|
* newPassword: 'newSecurePassword456'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { ConnectorsModule, UserConnectorsModule } from "./connectors.types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Creates the Connectors module for the
|
|
4
|
+
* Creates the Connectors module for the Doany SDK.
|
|
5
5
|
*
|
|
6
6
|
* @param axios - Axios instance (should be service role client)
|
|
7
7
|
* @param appId - Application ID
|
|
@@ -10,7 +10,7 @@ export interface ConnectorIntegrationTypeRegistry {
|
|
|
10
10
|
* ```typescript
|
|
11
11
|
* // Using generated connector type names
|
|
12
12
|
* // With generated types, you get autocomplete on integration types
|
|
13
|
-
* const connection = await
|
|
13
|
+
* const connection = await doany.asServiceRole.connectors.getConnection('googlecalendar');
|
|
14
14
|
* const token = connection.accessToken;
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
@@ -56,7 +56,7 @@ export interface AppUserConnectorConnectionResponse {
|
|
|
56
56
|
* All app users share a single OAuth token. Use this for shared accounts. For example, posting to a company Slack channel or reading from a shared Google Calendar. To use a shared connector:
|
|
57
57
|
*
|
|
58
58
|
* 1. Connect the external service account in the app's Integration settings or using the [`connectors push`](/developers/references/cli/commands/connectors-push) CLI command.
|
|
59
|
-
* 2. In a backend function, call {@linkcode getConnection | getConnection()} using the service role client (`
|
|
59
|
+
* 2. In a backend function, call {@linkcode getConnection | getConnection()} using the service role client (`doany.asServiceRole.connectors`) with an [integration type](#available-connectors) string to retrieve the shared OAuth token.
|
|
60
60
|
* 3. Use the returned `accessToken` to call the external service's API directly. Some connectors also return a `connectionConfig` with additional values such as a subdomain for building the API URL.
|
|
61
61
|
*
|
|
62
62
|
* ## App user connectors
|
|
@@ -65,7 +65,7 @@ export interface AppUserConnectorConnectionResponse {
|
|
|
65
65
|
*
|
|
66
66
|
* 1. Register OAuth credentials for the service in Workspace Settings to get a **connector ID**. This requires workspace admin access.
|
|
67
67
|
* 2. From the frontend, call [connectAppUser()](#connectappuser) with the connector ID to get an authorization URL, then redirect the app user to that URL to complete the OAuth flow.
|
|
68
|
-
* 3. In a backend function, call {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()} using the service role client (`
|
|
68
|
+
* 3. In a backend function, call {@linkcode getCurrentAppUserConnection | getCurrentAppUserConnection()} using the service role client (`doany.asServiceRole.connectors`) with the connector ID to retrieve the app user's token.
|
|
69
69
|
* 4. Use the returned `accessToken` to call the external service's API directly. Some connectors also return a `connectionConfig` with additional values such as a subdomain for building the API URL.
|
|
70
70
|
*
|
|
71
71
|
* ## Available connectors
|
|
@@ -123,8 +123,8 @@ export interface AppUserConnectorConnectionResponse {
|
|
|
123
123
|
*
|
|
124
124
|
* See the integration guides for more details:
|
|
125
125
|
*
|
|
126
|
-
* - **Scopes and permissions**: {@link https://docs.
|
|
127
|
-
* - **Slack connector types**: {@link https://docs.
|
|
126
|
+
* - **Scopes and permissions**: {@link https://docs.doany.com/Integrations/gmail-connector#gmail-scopes-and-permissions | Gmail}, {@link https://docs.doany.com/Integrations/linkedin-connector#linkedin-scopes-and-permissions | LinkedIn}, {@link https://docs.doany.com/Integrations/slack-connector#slack-scopes-and-permissions | Slack}, {@link https://docs.doany.com/Integrations/github-connector#github-scopes-and-permissions | GitHub}
|
|
127
|
+
* - **Slack connector types**: {@link https://docs.doany.com/Integrations/slack-connector#about-the-slack-connectors | About the Slack connectors} explains the difference between `slack` and `slackbot`
|
|
128
128
|
*
|
|
129
129
|
* ## Dynamic Types
|
|
130
130
|
*
|
|
@@ -146,7 +146,7 @@ export interface ConnectorsModule {
|
|
|
146
146
|
* ```typescript
|
|
147
147
|
* // Google Calendar connection
|
|
148
148
|
* // Get Google Calendar OAuth token and fetch upcoming events
|
|
149
|
-
* const googleToken = await
|
|
149
|
+
* const googleToken = await doany.asServiceRole.connectors.getAccessToken('googlecalendar');
|
|
150
150
|
*
|
|
151
151
|
* // Fetch upcoming 10 events
|
|
152
152
|
* const timeMin = new Date().toISOString();
|
|
@@ -163,7 +163,7 @@ export interface ConnectorsModule {
|
|
|
163
163
|
* ```typescript
|
|
164
164
|
* // Slack User connection
|
|
165
165
|
* // Get Slack user token and list channels
|
|
166
|
-
* const slackToken = await
|
|
166
|
+
* const slackToken = await doany.asServiceRole.connectors.getAccessToken('slack');
|
|
167
167
|
*
|
|
168
168
|
* // List all public and private channels
|
|
169
169
|
* const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
|
|
@@ -179,7 +179,7 @@ export interface ConnectorsModule {
|
|
|
179
179
|
* ```typescript
|
|
180
180
|
* // Slack Bot connection
|
|
181
181
|
* // Get Slack bot token and post a message with a custom bot identity
|
|
182
|
-
* const botToken = await
|
|
182
|
+
* const botToken = await doany.asServiceRole.connectors.getAccessToken('slackbot');
|
|
183
183
|
*
|
|
184
184
|
* const response = await fetch('https://slack.com/api/chat.postMessage', {
|
|
185
185
|
* method: 'POST',
|
|
@@ -216,7 +216,7 @@ export interface ConnectorsModule {
|
|
|
216
216
|
* @example
|
|
217
217
|
* ```typescript
|
|
218
218
|
* // Google Calendar connection
|
|
219
|
-
* const { accessToken } = await
|
|
219
|
+
* const { accessToken } = await doany.asServiceRole.connectors.getConnection('googlecalendar');
|
|
220
220
|
*
|
|
221
221
|
* const response = await fetch('https://www.googleapis.com/calendar/v3/users/me/calendarList', {
|
|
222
222
|
* headers: { Authorization: `Bearer ${accessToken}` }
|
|
@@ -229,7 +229,7 @@ export interface ConnectorsModule {
|
|
|
229
229
|
* ```typescript
|
|
230
230
|
* // Slack connection
|
|
231
231
|
* // Get Slack OAuth token and list channels
|
|
232
|
-
* const { accessToken } = await
|
|
232
|
+
* const { accessToken } = await doany.asServiceRole.connectors.getConnection('slack');
|
|
233
233
|
*
|
|
234
234
|
* const url = 'https://slack.com/api/conversations.list?types=public_channel,private_channel&limit=100';
|
|
235
235
|
*
|
|
@@ -244,7 +244,7 @@ export interface ConnectorsModule {
|
|
|
244
244
|
* ```typescript
|
|
245
245
|
* // Using connectionConfig
|
|
246
246
|
* // Some connectors return a subdomain or other params needed to build the API URL
|
|
247
|
-
* const { accessToken, connectionConfig } = await
|
|
247
|
+
* const { accessToken, connectionConfig } = await doany.asServiceRole.connectors.getConnection('myservice');
|
|
248
248
|
*
|
|
249
249
|
* const subdomain = connectionConfig?.subdomain;
|
|
250
250
|
* const response = await fetch(
|
|
@@ -272,7 +272,7 @@ export interface ConnectorsModule {
|
|
|
272
272
|
* @example
|
|
273
273
|
* ```typescript
|
|
274
274
|
* // Get the connection for a workspace-registered connector
|
|
275
|
-
* const { accessToken, connectionConfig } = await
|
|
275
|
+
* const { accessToken, connectionConfig } = await doany.asServiceRole.connectors.getWorkspaceConnection(
|
|
276
276
|
* 'abc123def',
|
|
277
277
|
* );
|
|
278
278
|
*
|
|
@@ -290,7 +290,7 @@ export interface ConnectorsModule {
|
|
|
290
290
|
/**
|
|
291
291
|
* Retrieves the OAuth access token and connection configuration for an [app user connector](#app-user-connectors).
|
|
292
292
|
*
|
|
293
|
-
* The token returned is specific to the app user making the current request. For this to work, the SDK client must know which app user to act on behalf of. Use {@linkcode createClientFromRequest | createClientFromRequest()} in a
|
|
293
|
+
* The token returned is specific to the app user making the current request. For this to work, the SDK client must know which app user to act on behalf of. Use {@linkcode createClientFromRequest | createClientFromRequest()} in a Doany backend function to create such a client. It reads the app user's JWT from the incoming request and attaches it automatically so the runtime can resolve the correct user's connection.
|
|
294
294
|
*
|
|
295
295
|
* The connector must be registered in Workspace Settings with OAuth credentials before this method can return a connection. The app user must also have completed the OAuth flow using [connectAppUser()](#connectappuser).
|
|
296
296
|
*
|
|
@@ -300,7 +300,7 @@ export interface ConnectorsModule {
|
|
|
300
300
|
* @example
|
|
301
301
|
* ```typescript
|
|
302
302
|
* // Basic usage
|
|
303
|
-
* const { accessToken } = await
|
|
303
|
+
* const { accessToken } = await doany.asServiceRole.connectors.getCurrentAppUserConnection('abc123def');
|
|
304
304
|
*
|
|
305
305
|
* const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
|
|
306
306
|
* headers: { Authorization: `Bearer ${accessToken}` }
|
|
@@ -312,7 +312,7 @@ export interface ConnectorsModule {
|
|
|
312
312
|
* @example
|
|
313
313
|
* ```typescript
|
|
314
314
|
* // Using connectionConfig
|
|
315
|
-
* const { accessToken, connectionConfig } = await
|
|
315
|
+
* const { accessToken, connectionConfig } = await doany.asServiceRole.connectors.getCurrentAppUserConnection('abc123def');
|
|
316
316
|
*
|
|
317
317
|
* const subdomain = connectionConfig?.subdomain;
|
|
318
318
|
* const response = await fetch(
|
|
@@ -334,7 +334,7 @@ export interface ConnectorsModule {
|
|
|
334
334
|
* this module manages tokens scoped to individual app users. Methods are keyed on
|
|
335
335
|
* the connector ID, not the integration type.
|
|
336
336
|
*
|
|
337
|
-
* Available via `
|
|
337
|
+
* Available via `doany.connectors`.
|
|
338
338
|
*/
|
|
339
339
|
export interface UserConnectorsModule {
|
|
340
340
|
/**
|
|
@@ -350,7 +350,7 @@ export interface UserConnectorsModule {
|
|
|
350
350
|
* @example
|
|
351
351
|
* ```typescript
|
|
352
352
|
* // Start OAuth for the app user
|
|
353
|
-
* const redirectUrl = await
|
|
353
|
+
* const redirectUrl = await doany.connectors.connectAppUser('abc123def');
|
|
354
354
|
*
|
|
355
355
|
* // Redirect the user to the OAuth provider
|
|
356
356
|
* window.location.href = redirectUrl;
|
|
@@ -369,7 +369,7 @@ export interface UserConnectorsModule {
|
|
|
369
369
|
* @example
|
|
370
370
|
* ```typescript
|
|
371
371
|
* // Disconnect the app user's connection
|
|
372
|
-
* await
|
|
372
|
+
* await doany.connectors.disconnectAppUser('abc123def');
|
|
373
373
|
* ```
|
|
374
374
|
*/
|
|
375
375
|
disconnectAppUser(connectorId: string): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { CustomIntegrationsModule } from "./custom-integrations.types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Creates the custom integrations module for the
|
|
4
|
+
* Creates the custom integrations module for the Doany SDK.
|
|
5
5
|
*
|
|
6
6
|
* @param axios - Axios instance for making HTTP requests
|
|
7
7
|
* @param appId - Application ID
|
|
@@ -51,14 +51,14 @@ export interface CustomIntegrationsModule {
|
|
|
51
51
|
*
|
|
52
52
|
* @throws {Error} If slug is not provided.
|
|
53
53
|
* @throws {Error} If operationId is not provided.
|
|
54
|
-
* @throws {
|
|
55
|
-
* @throws {
|
|
56
|
-
* @throws {
|
|
54
|
+
* @throws {DoanyError} If the integration or operation is not found (404).
|
|
55
|
+
* @throws {DoanyError} If the external API call fails (502).
|
|
56
|
+
* @throws {DoanyError} If the request times out (504).
|
|
57
57
|
*
|
|
58
58
|
* @example
|
|
59
59
|
* ```typescript
|
|
60
60
|
* // Call a custom CRM integration
|
|
61
|
-
* const response = await
|
|
61
|
+
* const response = await doany.integrations.custom.call(
|
|
62
62
|
* "my-crm",
|
|
63
63
|
* "get:/contacts",
|
|
64
64
|
* { queryParams: { limit: 10 } }
|
|
@@ -72,7 +72,7 @@ export interface CustomIntegrationsModule {
|
|
|
72
72
|
* @example
|
|
73
73
|
* ```typescript
|
|
74
74
|
* // Call with path params and request body
|
|
75
|
-
* const response = await
|
|
75
|
+
* const response = await doany.integrations.custom.call(
|
|
76
76
|
* "github",
|
|
77
77
|
* "post:/repos/{owner}/{repo}/issues",
|
|
78
78
|
* {
|
|
@@ -11,7 +11,7 @@ export interface EntitiesModuleConfig {
|
|
|
11
11
|
getSocket: () => ReturnType<typeof RoomsSocket>;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* Creates the entities module for the
|
|
14
|
+
* Creates the entities module for the Doany SDK.
|
|
15
15
|
*
|
|
16
16
|
* @param config - Configuration object containing axios, appId, and getSocket
|
|
17
17
|
* @returns Entities module with dynamic entity access
|
package/dist/modules/entities.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Creates the entities module for the
|
|
2
|
+
* Creates the entities module for the Doany SDK.
|
|
3
3
|
*
|
|
4
4
|
* @param config - Configuration object containing axios, appId, and getSocket
|
|
5
5
|
* @returns Entities module with dynamic entity access
|
|
@@ -37,7 +37,7 @@ function parseRealtimeMessage(dataStr) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
|
40
|
-
console.warn("[
|
|
40
|
+
console.warn("[Doany SDK] Failed to parse realtime message:", error);
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -145,7 +145,7 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
145
145
|
// rendering the slimmed payload directly. Skip on delete events
|
|
146
146
|
// — the record no longer exists.
|
|
147
147
|
if (event.type !== "delete" && ((_a = event.data) === null || _a === void 0 ? void 0 : _a._oversize)) {
|
|
148
|
-
console.error(`[
|
|
148
|
+
console.error(`[Doany SDK] Realtime broadcast for ${entityName}#${event.id} was oversize and got slimmed for transport. ` +
|
|
149
149
|
`Fields >10 KB are empty and the rest of the record may be a stub. ` +
|
|
150
150
|
`Call \`entities.${entityName}.get("${event.id}")\` to fetch the full record.`);
|
|
151
151
|
}
|
|
@@ -153,7 +153,7 @@ function createEntityHandler(axios, appId, entityName, getSocket) {
|
|
|
153
153
|
callback(event);
|
|
154
154
|
}
|
|
155
155
|
catch (error) {
|
|
156
|
-
console.error("[
|
|
156
|
+
console.error("[Doany SDK] Subscription callback error:", error);
|
|
157
157
|
}
|
|
158
158
|
},
|
|
159
159
|
});
|