@scryme/chat 2.91.88 → 2.91.90
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/sdk.d.ts +90 -0
- package/dist/sdk.js +61 -1
- package/package.json +1 -1
- package/src/__tests__/sdk.test.ts +34 -7
- package/src/sdk.ts +129 -1
package/dist/sdk.d.ts
CHANGED
|
@@ -630,6 +630,27 @@ export declare class ScrymeSDK {
|
|
|
630
630
|
* @returns Workspace member deletion confirmation exactly from the endpoint.
|
|
631
631
|
*/
|
|
632
632
|
delete: (slug: string, memberId: string, options?: AxiosRequestConfig) => Promise<V3DeleteWorkspaceMemberResponse>;
|
|
633
|
+
/**
|
|
634
|
+
* Bulk imports members from an external system into a workspace.
|
|
635
|
+
* @param slug Unique workspace slug.
|
|
636
|
+
* @param data Object containing array of members to import.
|
|
637
|
+
* @param options Optional request config override.
|
|
638
|
+
*/
|
|
639
|
+
import: (slug: string, data: {
|
|
640
|
+
members: Array<{
|
|
641
|
+
email: string;
|
|
642
|
+
name?: string;
|
|
643
|
+
avatar?: string;
|
|
644
|
+
role?: string;
|
|
645
|
+
externalId?: string;
|
|
646
|
+
}>;
|
|
647
|
+
}, options?: AxiosRequestConfig) => Promise<{
|
|
648
|
+
success: boolean;
|
|
649
|
+
data: {
|
|
650
|
+
importedCount: number;
|
|
651
|
+
members: any[];
|
|
652
|
+
};
|
|
653
|
+
}>;
|
|
633
654
|
};
|
|
634
655
|
/**
|
|
635
656
|
* Operations for listing and creating channels inside a workspace.
|
|
@@ -954,6 +975,22 @@ export declare class ScrymeSDK {
|
|
|
954
975
|
* @returns List of matching user profiles returned exactly from the endpoint.
|
|
955
976
|
*/
|
|
956
977
|
search: (params: UsersControllerSearchUsersParams, options?: AxiosRequestConfig) => Promise<UserProfile[]>;
|
|
978
|
+
/**
|
|
979
|
+
* Creates or provisions a user account via Enterprise M2M V3 API.
|
|
980
|
+
* @param data User account configuration (email, name, avatar, organizationId).
|
|
981
|
+
* @param options Optional request config override.
|
|
982
|
+
*/
|
|
983
|
+
create: (data: {
|
|
984
|
+
email: string;
|
|
985
|
+
name?: string;
|
|
986
|
+
avatar?: string;
|
|
987
|
+
organizationId?: string;
|
|
988
|
+
}, options?: AxiosRequestConfig) => Promise<{
|
|
989
|
+
success: boolean;
|
|
990
|
+
data: {
|
|
991
|
+
user: UserProfile;
|
|
992
|
+
};
|
|
993
|
+
}>;
|
|
957
994
|
};
|
|
958
995
|
/**
|
|
959
996
|
* Operations for managing webhooks (both standard workspace webhooks and channel incoming webhooks).
|
|
@@ -1356,6 +1393,59 @@ export declare class ScrymeSDK {
|
|
|
1356
1393
|
* @param options Optional request config override.
|
|
1357
1394
|
*/
|
|
1358
1395
|
delete: (slug: string, memberId: string, options?: AxiosRequestConfig) => Promise<V3DeleteWorkspaceMemberResponse>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Bulk imports members from an external system into a workspace.
|
|
1398
|
+
* @param slug Unique workspace slug.
|
|
1399
|
+
* @param data Object containing array of members to import.
|
|
1400
|
+
* @param options Optional request config override.
|
|
1401
|
+
*/
|
|
1402
|
+
import: (slug: string, data: {
|
|
1403
|
+
members: Array<{
|
|
1404
|
+
email: string;
|
|
1405
|
+
name?: string;
|
|
1406
|
+
avatar?: string;
|
|
1407
|
+
role?: string;
|
|
1408
|
+
externalId?: string;
|
|
1409
|
+
}>;
|
|
1410
|
+
}, options?: AxiosRequestConfig) => Promise<{
|
|
1411
|
+
success: boolean;
|
|
1412
|
+
data: {
|
|
1413
|
+
importedCount: number;
|
|
1414
|
+
members: any[];
|
|
1415
|
+
};
|
|
1416
|
+
}>;
|
|
1417
|
+
};
|
|
1418
|
+
/**
|
|
1419
|
+
* M2M User Account Operations (Creating/provisioning users and querying accounts).
|
|
1420
|
+
*/
|
|
1421
|
+
user: {
|
|
1422
|
+
/**
|
|
1423
|
+
* Creates or provisions a new user account in the system.
|
|
1424
|
+
* @param data User account details (email, name, avatar, organizationId).
|
|
1425
|
+
* @param options Optional request config override.
|
|
1426
|
+
*/
|
|
1427
|
+
create: (data: {
|
|
1428
|
+
email: string;
|
|
1429
|
+
name?: string;
|
|
1430
|
+
avatar?: string;
|
|
1431
|
+
organizationId?: string;
|
|
1432
|
+
}, options?: AxiosRequestConfig) => Promise<{
|
|
1433
|
+
success: boolean;
|
|
1434
|
+
data: {
|
|
1435
|
+
user: UserProfile;
|
|
1436
|
+
};
|
|
1437
|
+
}>;
|
|
1438
|
+
/**
|
|
1439
|
+
* Retrieves user account profile details by user ID or email.
|
|
1440
|
+
* @param userIdOrEmail User ID or email address.
|
|
1441
|
+
* @param options Optional request config override.
|
|
1442
|
+
*/
|
|
1443
|
+
get: (userIdOrEmail: string, options?: AxiosRequestConfig) => Promise<{
|
|
1444
|
+
success: boolean;
|
|
1445
|
+
data: {
|
|
1446
|
+
user: UserProfile;
|
|
1447
|
+
};
|
|
1448
|
+
}>;
|
|
1359
1449
|
};
|
|
1360
1450
|
/**
|
|
1361
1451
|
* M2M Authentication and Token Management Utilities.
|
package/dist/sdk.js
CHANGED
|
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
57
|
import axios from 'axios';
|
|
58
|
-
import { setGlobalToken, parseSDKError } from './custom-instance';
|
|
58
|
+
import { setGlobalToken, parseSDKError, customInstance } from './custom-instance';
|
|
59
59
|
import { getSkyrmeChatAPI } from './generated/v3-server';
|
|
60
60
|
/**
|
|
61
61
|
* The primary client SDK class for accessing the Scryme Chat platform APIs.
|
|
@@ -395,6 +395,17 @@ var ScrymeSDK = /** @class */ (function () {
|
|
|
395
395
|
return [2 /*return*/, this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options)];
|
|
396
396
|
});
|
|
397
397
|
}); },
|
|
398
|
+
/**
|
|
399
|
+
* Bulk imports members from an external system into a workspace.
|
|
400
|
+
* @param slug Unique workspace slug.
|
|
401
|
+
* @param data Object containing array of members to import.
|
|
402
|
+
* @param options Optional request config override.
|
|
403
|
+
*/
|
|
404
|
+
import: function (slug, data, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
405
|
+
return __generator(this, function (_a) {
|
|
406
|
+
return [2 /*return*/, customInstance(__assign({ url: "/api/v3/workspaces/".concat(encodeURIComponent(slug), "/members/import"), method: 'POST', data: data, headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
407
|
+
});
|
|
408
|
+
}); },
|
|
398
409
|
},
|
|
399
410
|
/**
|
|
400
411
|
* Operations for listing and creating channels inside a workspace.
|
|
@@ -1047,6 +1058,16 @@ var ScrymeSDK = /** @class */ (function () {
|
|
|
1047
1058
|
return [2 /*return*/, this.raw.usersControllerSearchUsers(params, options)];
|
|
1048
1059
|
});
|
|
1049
1060
|
}); },
|
|
1061
|
+
/**
|
|
1062
|
+
* Creates or provisions a user account via Enterprise M2M V3 API.
|
|
1063
|
+
* @param data User account configuration (email, name, avatar, organizationId).
|
|
1064
|
+
* @param options Optional request config override.
|
|
1065
|
+
*/
|
|
1066
|
+
create: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
1067
|
+
return __generator(this, function (_a) {
|
|
1068
|
+
return [2 /*return*/, customInstance(__assign({ url: '/api/v3/users', method: 'POST', data: data, headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
1069
|
+
});
|
|
1070
|
+
}); },
|
|
1050
1071
|
};
|
|
1051
1072
|
},
|
|
1052
1073
|
enumerable: false,
|
|
@@ -1597,6 +1618,45 @@ var ScrymeSDK = /** @class */ (function () {
|
|
|
1597
1618
|
return [2 /*return*/, this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options)];
|
|
1598
1619
|
});
|
|
1599
1620
|
}); },
|
|
1621
|
+
/**
|
|
1622
|
+
* Bulk imports members from an external system into a workspace.
|
|
1623
|
+
* @param slug Unique workspace slug.
|
|
1624
|
+
* @param data Object containing array of members to import.
|
|
1625
|
+
* @param options Optional request config override.
|
|
1626
|
+
*/
|
|
1627
|
+
import: function (slug, data, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
1628
|
+
return __generator(this, function (_a) {
|
|
1629
|
+
return [2 /*return*/, customInstance(__assign({ url: "/api/v3/workspaces/".concat(encodeURIComponent(slug), "/members/import"), method: 'POST', data: data, headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
1630
|
+
});
|
|
1631
|
+
}); },
|
|
1632
|
+
},
|
|
1633
|
+
/**
|
|
1634
|
+
* M2M User Account Operations (Creating/provisioning users and querying accounts).
|
|
1635
|
+
*/
|
|
1636
|
+
user: {
|
|
1637
|
+
/**
|
|
1638
|
+
* Creates or provisions a new user account in the system.
|
|
1639
|
+
* @param data User account details (email, name, avatar, organizationId).
|
|
1640
|
+
* @param options Optional request config override.
|
|
1641
|
+
*/
|
|
1642
|
+
create: function (data, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
1643
|
+
return __generator(this, function (_a) {
|
|
1644
|
+
return [2 /*return*/, customInstance(__assign({ url: '/api/v3/users', method: 'POST', data: data, headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
1645
|
+
});
|
|
1646
|
+
}); },
|
|
1647
|
+
/**
|
|
1648
|
+
* Retrieves user account profile details by user ID or email.
|
|
1649
|
+
* @param userIdOrEmail User ID or email address.
|
|
1650
|
+
* @param options Optional request config override.
|
|
1651
|
+
*/
|
|
1652
|
+
get: function (userIdOrEmail, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
1653
|
+
return __generator(this, function (_a) {
|
|
1654
|
+
if (userIdOrEmail.includes('@')) {
|
|
1655
|
+
return [2 /*return*/, customInstance(__assign({ url: "/api/v3/users/by-email?email=".concat(encodeURIComponent(userIdOrEmail)), method: 'GET', headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
1656
|
+
}
|
|
1657
|
+
return [2 /*return*/, customInstance(__assign({ url: "/api/v3/users/".concat(encodeURIComponent(userIdOrEmail)), method: 'GET', headers: options === null || options === void 0 ? void 0 : options.headers }, options))];
|
|
1658
|
+
});
|
|
1659
|
+
}); },
|
|
1600
1660
|
},
|
|
1601
1661
|
/**
|
|
1602
1662
|
* M2M Authentication and Token Management Utilities.
|
package/package.json
CHANGED
|
@@ -4,16 +4,20 @@ import { ScrymeSDK } from '../sdk';
|
|
|
4
4
|
|
|
5
5
|
vi.mock('axios', async () => {
|
|
6
6
|
const actual = await vi.importActual<typeof axios>('axios');
|
|
7
|
+
const instanceFn = vi.fn(async (config) => ({
|
|
8
|
+
data: { success: true, data: { importedCount: 1, members: [], user: { id: 'usr_123' } } },
|
|
9
|
+
headers: {},
|
|
10
|
+
}));
|
|
11
|
+
(instanceFn as any).interceptors = {
|
|
12
|
+
request: { use: vi.fn(), eject: vi.fn() },
|
|
13
|
+
response: { use: vi.fn(), eject: vi.fn() },
|
|
14
|
+
};
|
|
15
|
+
(instanceFn as any).defaults = { headers: {} };
|
|
16
|
+
|
|
7
17
|
return {
|
|
8
18
|
default: {
|
|
9
19
|
...actual,
|
|
10
|
-
create: vi.fn(() =>
|
|
11
|
-
interceptors: {
|
|
12
|
-
request: { use: vi.fn(), eject: vi.fn() },
|
|
13
|
-
response: { use: vi.fn(), eject: vi.fn() },
|
|
14
|
-
},
|
|
15
|
-
defaults: { headers: {} },
|
|
16
|
-
})),
|
|
20
|
+
create: vi.fn(() => instanceFn),
|
|
17
21
|
post: vi.fn(),
|
|
18
22
|
},
|
|
19
23
|
};
|
|
@@ -633,5 +637,28 @@ describe('ScrymeSDK', () => {
|
|
|
633
637
|
const custGet = await sdk.support.customer.getProfiles('ws-123') as any;
|
|
634
638
|
expect(custGet.workspaceId).toBe('ws-123');
|
|
635
639
|
});
|
|
640
|
+
|
|
641
|
+
it('should support bulk member import and user creation in workspace, user, and m2m namespaces', async () => {
|
|
642
|
+
const sdk = new ScrymeSDK({
|
|
643
|
+
baseURL: 'https://api.test.com',
|
|
644
|
+
token: 'active-token',
|
|
645
|
+
});
|
|
646
|
+
|
|
647
|
+
const importRes = await sdk.workspace.members.import('acme-corp', {
|
|
648
|
+
members: [{ email: 'alice@acme.com', name: 'Alice' }, { email: 'bob@acme.com', name: 'Bob' }],
|
|
649
|
+
});
|
|
650
|
+
expect(importRes).toBeDefined();
|
|
651
|
+
|
|
652
|
+
const createRes = await sdk.user.create({ email: 'charlie@acme.com', name: 'Charlie' });
|
|
653
|
+
expect(createRes).toBeDefined();
|
|
654
|
+
|
|
655
|
+
const m2mImportRes = await sdk.m2m.member.import('acme-corp', {
|
|
656
|
+
members: [{ email: 'david@acme.com', name: 'David' }],
|
|
657
|
+
});
|
|
658
|
+
expect(m2mImportRes).toBeDefined();
|
|
659
|
+
|
|
660
|
+
const m2mCreateRes = await sdk.m2m.user.create({ email: 'eve@acme.com', name: 'Eve' });
|
|
661
|
+
expect(m2mCreateRes).toBeDefined();
|
|
662
|
+
});
|
|
636
663
|
});
|
|
637
664
|
});
|
package/src/sdk.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios, { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { setGlobalToken, parseSDKError } from './custom-instance';
|
|
2
|
+
import { setGlobalToken, parseSDKError, customInstance } from './custom-instance';
|
|
3
3
|
import { getSkyrmeChatAPI } from './generated/v3-server';
|
|
4
4
|
import type {
|
|
5
5
|
V3ProvisionWorkspaceDto,
|
|
@@ -935,6 +935,33 @@ export class ScrymeSDK {
|
|
|
935
935
|
): Promise<V3DeleteWorkspaceMemberResponse> => {
|
|
936
936
|
return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options) as unknown as V3DeleteWorkspaceMemberResponse;
|
|
937
937
|
},
|
|
938
|
+
/**
|
|
939
|
+
* Bulk imports members from an external system into a workspace.
|
|
940
|
+
* @param slug Unique workspace slug.
|
|
941
|
+
* @param data Object containing array of members to import.
|
|
942
|
+
* @param options Optional request config override.
|
|
943
|
+
*/
|
|
944
|
+
import: async (
|
|
945
|
+
slug: string,
|
|
946
|
+
data: {
|
|
947
|
+
members: Array<{
|
|
948
|
+
email: string;
|
|
949
|
+
name?: string;
|
|
950
|
+
avatar?: string;
|
|
951
|
+
role?: string;
|
|
952
|
+
externalId?: string;
|
|
953
|
+
}>;
|
|
954
|
+
},
|
|
955
|
+
options?: AxiosRequestConfig
|
|
956
|
+
): Promise<{ success: boolean; data: { importedCount: number; members: any[] } }> => {
|
|
957
|
+
return customInstance({
|
|
958
|
+
url: `/api/v3/workspaces/${encodeURIComponent(slug)}/members/import`,
|
|
959
|
+
method: 'POST',
|
|
960
|
+
data,
|
|
961
|
+
headers: options?.headers,
|
|
962
|
+
...options,
|
|
963
|
+
});
|
|
964
|
+
},
|
|
938
965
|
},
|
|
939
966
|
/**
|
|
940
967
|
* Operations for listing and creating channels inside a workspace.
|
|
@@ -1571,6 +1598,28 @@ export class ScrymeSDK {
|
|
|
1571
1598
|
): Promise<UserProfile[]> => {
|
|
1572
1599
|
return this.raw.usersControllerSearchUsers(params, options) as unknown as UserProfile[];
|
|
1573
1600
|
},
|
|
1601
|
+
/**
|
|
1602
|
+
* Creates or provisions a user account via Enterprise M2M V3 API.
|
|
1603
|
+
* @param data User account configuration (email, name, avatar, organizationId).
|
|
1604
|
+
* @param options Optional request config override.
|
|
1605
|
+
*/
|
|
1606
|
+
create: async (
|
|
1607
|
+
data: {
|
|
1608
|
+
email: string;
|
|
1609
|
+
name?: string;
|
|
1610
|
+
avatar?: string;
|
|
1611
|
+
organizationId?: string;
|
|
1612
|
+
},
|
|
1613
|
+
options?: AxiosRequestConfig
|
|
1614
|
+
): Promise<{ success: boolean; data: { user: UserProfile } }> => {
|
|
1615
|
+
return customInstance({
|
|
1616
|
+
url: '/api/v3/users',
|
|
1617
|
+
method: 'POST',
|
|
1618
|
+
data,
|
|
1619
|
+
headers: options?.headers,
|
|
1620
|
+
...options,
|
|
1621
|
+
});
|
|
1622
|
+
},
|
|
1574
1623
|
};
|
|
1575
1624
|
}
|
|
1576
1625
|
|
|
@@ -2237,6 +2286,85 @@ export class ScrymeSDK {
|
|
|
2237
2286
|
): Promise<V3DeleteWorkspaceMemberResponse> => {
|
|
2238
2287
|
return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options) as unknown as V3DeleteWorkspaceMemberResponse;
|
|
2239
2288
|
},
|
|
2289
|
+
/**
|
|
2290
|
+
* Bulk imports members from an external system into a workspace.
|
|
2291
|
+
* @param slug Unique workspace slug.
|
|
2292
|
+
* @param data Object containing array of members to import.
|
|
2293
|
+
* @param options Optional request config override.
|
|
2294
|
+
*/
|
|
2295
|
+
import: async (
|
|
2296
|
+
slug: string,
|
|
2297
|
+
data: {
|
|
2298
|
+
members: Array<{
|
|
2299
|
+
email: string;
|
|
2300
|
+
name?: string;
|
|
2301
|
+
avatar?: string;
|
|
2302
|
+
role?: string;
|
|
2303
|
+
externalId?: string;
|
|
2304
|
+
}>;
|
|
2305
|
+
},
|
|
2306
|
+
options?: AxiosRequestConfig
|
|
2307
|
+
): Promise<{ success: boolean; data: { importedCount: number; members: any[] } }> => {
|
|
2308
|
+
return customInstance({
|
|
2309
|
+
url: `/api/v3/workspaces/${encodeURIComponent(slug)}/members/import`,
|
|
2310
|
+
method: 'POST',
|
|
2311
|
+
data,
|
|
2312
|
+
headers: options?.headers,
|
|
2313
|
+
...options,
|
|
2314
|
+
});
|
|
2315
|
+
},
|
|
2316
|
+
},
|
|
2317
|
+
|
|
2318
|
+
/**
|
|
2319
|
+
* M2M User Account Operations (Creating/provisioning users and querying accounts).
|
|
2320
|
+
*/
|
|
2321
|
+
user: {
|
|
2322
|
+
/**
|
|
2323
|
+
* Creates or provisions a new user account in the system.
|
|
2324
|
+
* @param data User account details (email, name, avatar, organizationId).
|
|
2325
|
+
* @param options Optional request config override.
|
|
2326
|
+
*/
|
|
2327
|
+
create: async (
|
|
2328
|
+
data: {
|
|
2329
|
+
email: string;
|
|
2330
|
+
name?: string;
|
|
2331
|
+
avatar?: string;
|
|
2332
|
+
organizationId?: string;
|
|
2333
|
+
},
|
|
2334
|
+
options?: AxiosRequestConfig
|
|
2335
|
+
): Promise<{ success: boolean; data: { user: UserProfile } }> => {
|
|
2336
|
+
return customInstance({
|
|
2337
|
+
url: '/api/v3/users',
|
|
2338
|
+
method: 'POST',
|
|
2339
|
+
data,
|
|
2340
|
+
headers: options?.headers,
|
|
2341
|
+
...options,
|
|
2342
|
+
});
|
|
2343
|
+
},
|
|
2344
|
+
/**
|
|
2345
|
+
* Retrieves user account profile details by user ID or email.
|
|
2346
|
+
* @param userIdOrEmail User ID or email address.
|
|
2347
|
+
* @param options Optional request config override.
|
|
2348
|
+
*/
|
|
2349
|
+
get: async (
|
|
2350
|
+
userIdOrEmail: string,
|
|
2351
|
+
options?: AxiosRequestConfig
|
|
2352
|
+
): Promise<{ success: boolean; data: { user: UserProfile } }> => {
|
|
2353
|
+
if (userIdOrEmail.includes('@')) {
|
|
2354
|
+
return customInstance({
|
|
2355
|
+
url: `/api/v3/users/by-email?email=${encodeURIComponent(userIdOrEmail)}`,
|
|
2356
|
+
method: 'GET',
|
|
2357
|
+
headers: options?.headers,
|
|
2358
|
+
...options,
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
return customInstance({
|
|
2362
|
+
url: `/api/v3/users/${encodeURIComponent(userIdOrEmail)}`,
|
|
2363
|
+
method: 'GET',
|
|
2364
|
+
headers: options?.headers,
|
|
2365
|
+
...options,
|
|
2366
|
+
});
|
|
2367
|
+
},
|
|
2240
2368
|
},
|
|
2241
2369
|
|
|
2242
2370
|
/**
|