@internxt/sdk 1.12.5 → 1.13.0
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/misc/location/index.d.ts +2 -4
- package/dist/misc/location/index.js +5 -15
- package/dist/schema.d.ts +11 -8
- package/package.json +18 -17
- package/dist/drive/users/inext.test.d.ts +0 -1
- package/dist/drive/users/inext.test.js +0 -100
- package/dist/meet/index.test.d.ts +0 -1
- package/dist/meet/index.test.js +0 -267
- package/dist/workspaces/index.test.d.ts +0 -1
- package/dist/workspaces/index.test.js +0 -903
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApiUrl } from '../../shared';
|
|
2
2
|
export interface UserLocation {
|
|
3
3
|
ip: string;
|
|
4
4
|
location: string;
|
|
5
5
|
}
|
|
6
6
|
export declare class Location {
|
|
7
7
|
private readonly client;
|
|
8
|
-
private readonly appDetails;
|
|
9
8
|
private constructor();
|
|
10
|
-
static client(apiUrl: ApiUrl
|
|
9
|
+
static client(apiUrl: ApiUrl): Location;
|
|
11
10
|
getUserLocation(): Promise<UserLocation>;
|
|
12
|
-
private basicUserHeaders;
|
|
13
11
|
}
|
|
@@ -37,31 +37,21 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.Location = void 0;
|
|
40
|
-
var headers_1 = require("../../shared/headers");
|
|
41
40
|
var client_1 = require("../../shared/http/client");
|
|
42
41
|
var Location = /** @class */ (function () {
|
|
43
|
-
function Location(apiUrl
|
|
44
|
-
this.client = client_1.HttpClient.create(apiUrl
|
|
45
|
-
this.appDetails = appDetails;
|
|
42
|
+
function Location(apiUrl) {
|
|
43
|
+
this.client = client_1.HttpClient.create(apiUrl);
|
|
46
44
|
}
|
|
47
|
-
Location.client = function (apiUrl
|
|
48
|
-
return new Location(apiUrl
|
|
45
|
+
Location.client = function (apiUrl) {
|
|
46
|
+
return new Location(apiUrl);
|
|
49
47
|
};
|
|
50
48
|
Location.prototype.getUserLocation = function () {
|
|
51
49
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
50
|
return __generator(this, function (_a) {
|
|
53
|
-
return [2 /*return*/, this.client.get('',
|
|
51
|
+
return [2 /*return*/, this.client.get('/', {})];
|
|
54
52
|
});
|
|
55
53
|
});
|
|
56
54
|
};
|
|
57
|
-
Location.prototype.basicUserHeaders = function () {
|
|
58
|
-
return (0, headers_1.basicHeaders)({
|
|
59
|
-
clientName: this.appDetails.clientName,
|
|
60
|
-
clientVersion: this.appDetails.clientVersion,
|
|
61
|
-
desktopToken: this.appDetails.desktopHeader,
|
|
62
|
-
customHeaders: this.appDetails.customHeaders,
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
55
|
return Location;
|
|
66
56
|
}());
|
|
67
57
|
exports.Location = Location;
|
package/dist/schema.d.ts
CHANGED
|
@@ -2809,7 +2809,7 @@ export interface paths {
|
|
|
2809
2809
|
};
|
|
2810
2810
|
get?: never;
|
|
2811
2811
|
put?: never;
|
|
2812
|
-
/** CLI platform login access */
|
|
2812
|
+
/** CLI/Rclone platform login access */
|
|
2813
2813
|
post: operations['AuthController_cliLoginAccess'];
|
|
2814
2814
|
delete?: never;
|
|
2815
2815
|
options?: never;
|
|
@@ -3196,6 +3196,7 @@ export interface components {
|
|
|
3196
3196
|
*/
|
|
3197
3197
|
type: string;
|
|
3198
3198
|
};
|
|
3199
|
+
Object: Record<string, never>;
|
|
3199
3200
|
MoveFileDto: {
|
|
3200
3201
|
/**
|
|
3201
3202
|
* @description New Destination Folder UUID
|
|
@@ -5115,11 +5116,13 @@ export interface operations {
|
|
|
5115
5116
|
/** @description Bucket ID filter */
|
|
5116
5117
|
bucket?: string;
|
|
5117
5118
|
/** @description Field to sort by */
|
|
5118
|
-
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | '
|
|
5119
|
+
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | 'uuid';
|
|
5119
5120
|
/** @description Sort order */
|
|
5120
5121
|
order?: 'ASC' | 'DESC';
|
|
5121
5122
|
/** @description Filter files updated after this date */
|
|
5122
5123
|
updatedAt?: string;
|
|
5124
|
+
/** @description The last file uuid of the provided list in the previous call */
|
|
5125
|
+
lastId?: components['schemas']['Object'];
|
|
5123
5126
|
};
|
|
5124
5127
|
header?: never;
|
|
5125
5128
|
path?: never;
|
|
@@ -5561,7 +5564,7 @@ export interface operations {
|
|
|
5561
5564
|
/** @description Offset for pagination */
|
|
5562
5565
|
offset: number;
|
|
5563
5566
|
/** @description Field to sort by */
|
|
5564
|
-
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | '
|
|
5567
|
+
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | 'uuid';
|
|
5565
5568
|
/** @description Sort order */
|
|
5566
5569
|
order?: 'ASC' | 'DESC';
|
|
5567
5570
|
};
|
|
@@ -5591,7 +5594,7 @@ export interface operations {
|
|
|
5591
5594
|
/** @description Offset for pagination */
|
|
5592
5595
|
offset: number;
|
|
5593
5596
|
/** @description Field to sort by */
|
|
5594
|
-
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | '
|
|
5597
|
+
sort?: 'updatedAt' | 'size' | 'id' | 'plainName' | 'uuid';
|
|
5595
5598
|
/** @description Sort order */
|
|
5596
5599
|
order?: 'ASC' | 'DESC';
|
|
5597
5600
|
};
|
|
@@ -5643,7 +5646,7 @@ export interface operations {
|
|
|
5643
5646
|
/** @description Offset for pagination */
|
|
5644
5647
|
offset: number;
|
|
5645
5648
|
/** @description Field to sort by */
|
|
5646
|
-
sort?: 'updatedAt' | 'id' | 'plainName' | '
|
|
5649
|
+
sort?: 'updatedAt' | 'id' | 'plainName' | 'uuid';
|
|
5647
5650
|
/** @description Sort order */
|
|
5648
5651
|
order?: 'ASC' | 'DESC';
|
|
5649
5652
|
};
|
|
@@ -5772,7 +5775,7 @@ export interface operations {
|
|
|
5772
5775
|
/** @description Offset for pagination */
|
|
5773
5776
|
offset: number;
|
|
5774
5777
|
/** @description Field to sort by */
|
|
5775
|
-
sort?: 'updatedAt' | 'id' | 'plainName' | '
|
|
5778
|
+
sort?: 'updatedAt' | 'id' | 'plainName' | 'uuid';
|
|
5776
5779
|
/** @description Sort order */
|
|
5777
5780
|
order?: 'ASC' | 'DESC';
|
|
5778
5781
|
};
|
|
@@ -9467,7 +9470,7 @@ export interface operations {
|
|
|
9467
9470
|
};
|
|
9468
9471
|
};
|
|
9469
9472
|
responses: {
|
|
9470
|
-
/** @description
|
|
9473
|
+
/** @description User successfully accessed their account via CLI or Rclone */
|
|
9471
9474
|
200: {
|
|
9472
9475
|
headers: {
|
|
9473
9476
|
[name: string]: unknown;
|
|
@@ -9476,7 +9479,7 @@ export interface operations {
|
|
|
9476
9479
|
'application/json': components['schemas']['LoginAccessResponseDto'];
|
|
9477
9480
|
};
|
|
9478
9481
|
};
|
|
9479
|
-
/** @description This user current tier does not allow CLI access */
|
|
9482
|
+
/** @description This user current tier does not allow CLI/Rclone access */
|
|
9480
9483
|
402: {
|
|
9481
9484
|
headers: {
|
|
9482
9485
|
[name: string]: unknown;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internxt/sdk",
|
|
3
3
|
"author": "Internxt <hello@internxt.com>",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.13.0",
|
|
5
5
|
"description": "An sdk for interacting with Internxt's services",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -19,35 +19,36 @@
|
|
|
19
19
|
"types": "dist/index.d.ts",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"prepare": "husky",
|
|
22
|
-
"test": "
|
|
23
|
-
"test:
|
|
24
|
-
"
|
|
22
|
+
"test": "vitest run --coverage",
|
|
23
|
+
"test:watch": "vitest watch",
|
|
24
|
+
"clean": "rimraf dist coverage tsconfig.tsbuildinfo",
|
|
25
|
+
"build": "yarn clean && tsc",
|
|
25
26
|
"lint": "eslint ./src",
|
|
26
|
-
"format": "prettier
|
|
27
|
+
"format": "prettier --write **/*.{js,jsx,tsx,ts}",
|
|
27
28
|
"swagger": "openapi-typescript https://gateway.internxt.com/drive/api-json -o ./src/schema.ts && yarn format"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@internxt/eslint-config-internxt": "2.0.1",
|
|
31
|
-
"@internxt/prettier-config": "
|
|
32
|
-
"@types/
|
|
33
|
-
"@
|
|
32
|
+
"@internxt/prettier-config": "internxt/prettier-config#v1.0.2",
|
|
33
|
+
"@types/node": "25.2.3",
|
|
34
|
+
"@vitest/coverage-istanbul": "4.0.18",
|
|
35
|
+
"@vitest/spy": "4.0.18",
|
|
34
36
|
"eslint": "9.39.2",
|
|
35
37
|
"husky": "9.1.7",
|
|
36
|
-
"jest": "30.2.0",
|
|
37
38
|
"lint-staged": "16.2.7",
|
|
38
|
-
"openapi-typescript": "7.
|
|
39
|
-
"prettier": "3.
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
39
|
+
"openapi-typescript": "7.12.0",
|
|
40
|
+
"prettier": "3.8.1",
|
|
41
|
+
"rimraf": "6.1.2",
|
|
42
|
+
"typescript": "5.9.3",
|
|
43
|
+
"vitest": "4.0.18"
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
|
-
"axios": "1.13.
|
|
46
|
-
"uuid": "
|
|
46
|
+
"axios": "1.13.5",
|
|
47
|
+
"uuid": "13.0.0"
|
|
47
48
|
},
|
|
48
49
|
"lint-staged": {
|
|
49
50
|
"*.{js,jsx,tsx,ts}": [
|
|
50
|
-
"
|
|
51
|
+
"prettier --write"
|
|
51
52
|
]
|
|
52
53
|
}
|
|
53
54
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var sinon_1 = __importDefault(require("sinon"));
|
|
43
|
-
var _1 = require(".");
|
|
44
|
-
var headers_1 = require("../../shared/headers");
|
|
45
|
-
var client_1 = require("../../shared/http/client");
|
|
46
|
-
var httpClient = client_1.HttpClient.create('');
|
|
47
|
-
describe('Users service tests', function () {
|
|
48
|
-
beforeEach(function () {
|
|
49
|
-
sinon_1.default.stub(client_1.HttpClient, 'create').returns(httpClient);
|
|
50
|
-
});
|
|
51
|
-
afterEach(function () {
|
|
52
|
-
sinon_1.default.restore();
|
|
53
|
-
});
|
|
54
|
-
describe('Users methods', function () {
|
|
55
|
-
describe('getPublicKeyWithPrecreation', function () {
|
|
56
|
-
it('should call the correct endpoint and return the public key response', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var email, publicKeyResponse, _a, client, headers, putCall, response;
|
|
58
|
-
return __generator(this, function (_b) {
|
|
59
|
-
switch (_b.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
email = 'test@example.com';
|
|
62
|
-
publicKeyResponse = {
|
|
63
|
-
publicKey: 'public_key_example_123',
|
|
64
|
-
publicKyberKey: 'kyber_key_example_123',
|
|
65
|
-
};
|
|
66
|
-
_a = clientAndHeaders(), client = _a.client, headers = _a.headers;
|
|
67
|
-
putCall = sinon_1.default.stub(httpClient, 'put').resolves(publicKeyResponse);
|
|
68
|
-
return [4 /*yield*/, client.getPublicKeyWithPrecreation({ email: email })];
|
|
69
|
-
case 1:
|
|
70
|
-
response = _b.sent();
|
|
71
|
-
expect(putCall.firstCall.args).toEqual(["/users/public-key/".concat(email), {}, headers]);
|
|
72
|
-
expect(response).toEqual(publicKeyResponse);
|
|
73
|
-
return [2 /*return*/];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
function clientAndHeaders(apiUrl, clientName, clientVersion, token) {
|
|
81
|
-
if (apiUrl === void 0) { apiUrl = ''; }
|
|
82
|
-
if (clientName === void 0) { clientName = 'c-name'; }
|
|
83
|
-
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
84
|
-
if (token === void 0) { token = 'my-token'; }
|
|
85
|
-
var appDetails = {
|
|
86
|
-
clientName: clientName,
|
|
87
|
-
clientVersion: clientVersion,
|
|
88
|
-
};
|
|
89
|
-
var apiSecurity = {
|
|
90
|
-
token: token,
|
|
91
|
-
unauthorizedCallback: function () { },
|
|
92
|
-
};
|
|
93
|
-
var client = _1.Users.client(apiUrl, appDetails, apiSecurity);
|
|
94
|
-
var headers = (0, headers_1.headersWithToken)({
|
|
95
|
-
clientName: clientName,
|
|
96
|
-
clientVersion: clientVersion,
|
|
97
|
-
token: token,
|
|
98
|
-
});
|
|
99
|
-
return { client: client, headers: headers };
|
|
100
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/meet/index.test.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var sinon_1 = __importDefault(require("sinon"));
|
|
43
|
-
var headers_1 = require("../shared/headers");
|
|
44
|
-
var client_1 = require("../shared/http/client");
|
|
45
|
-
var index_1 = require("./index");
|
|
46
|
-
var httpClient = client_1.HttpClient.create('');
|
|
47
|
-
describe('Meet service tests', function () {
|
|
48
|
-
beforeEach(function () {
|
|
49
|
-
sinon_1.default.stub(client_1.HttpClient, 'create').returns(httpClient);
|
|
50
|
-
});
|
|
51
|
-
afterEach(function () {
|
|
52
|
-
sinon_1.default.restore();
|
|
53
|
-
});
|
|
54
|
-
describe('createCall method', function () {
|
|
55
|
-
it('should successfully create a call with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var expectedResponse, _a, client, headers, postCall, response;
|
|
57
|
-
return __generator(this, function (_b) {
|
|
58
|
-
switch (_b.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
expectedResponse = {
|
|
61
|
-
token: 'call-token',
|
|
62
|
-
room: 'room-id',
|
|
63
|
-
paxPerCall: 10,
|
|
64
|
-
appId: 'app-id',
|
|
65
|
-
};
|
|
66
|
-
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
67
|
-
postCall = sinon_1.default.stub(httpClient, 'post').resolves(expectedResponse);
|
|
68
|
-
return [4 /*yield*/, client.createCall()];
|
|
69
|
-
case 1:
|
|
70
|
-
response = _b.sent();
|
|
71
|
-
// Assert
|
|
72
|
-
expect(postCall.firstCall.args).toEqual(['call', {}, headers]);
|
|
73
|
-
expect(response).toEqual(expectedResponse);
|
|
74
|
-
return [2 /*return*/];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}); });
|
|
78
|
-
it('should throw an error when token is missing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
-
var client;
|
|
80
|
-
return __generator(this, function (_a) {
|
|
81
|
-
switch (_a.label) {
|
|
82
|
-
case 0:
|
|
83
|
-
client = clientAndHeadersWithoutToken().client;
|
|
84
|
-
// Act & Assert
|
|
85
|
-
return [4 /*yield*/, expect(client.createCall()).rejects.toThrow('Token is required for Meet operations')];
|
|
86
|
-
case 1:
|
|
87
|
-
// Act & Assert
|
|
88
|
-
_a.sent();
|
|
89
|
-
return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}); });
|
|
93
|
-
});
|
|
94
|
-
describe('joinCall method', function () {
|
|
95
|
-
var callId = 'call-123';
|
|
96
|
-
var payload = {
|
|
97
|
-
name: 'John',
|
|
98
|
-
lastname: 'Doe',
|
|
99
|
-
anonymous: false,
|
|
100
|
-
};
|
|
101
|
-
var joinCallResponse = {
|
|
102
|
-
token: 'join-token',
|
|
103
|
-
room: 'room-id',
|
|
104
|
-
userId: 'user-123',
|
|
105
|
-
appId: 'app-id',
|
|
106
|
-
};
|
|
107
|
-
it('should join a call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
108
|
-
var _a, client, headers, postCall, response;
|
|
109
|
-
return __generator(this, function (_b) {
|
|
110
|
-
switch (_b.label) {
|
|
111
|
-
case 0:
|
|
112
|
-
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
113
|
-
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
114
|
-
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
115
|
-
case 1:
|
|
116
|
-
response = _b.sent();
|
|
117
|
-
// Assert
|
|
118
|
-
expect(postCall.firstCall.args).toEqual(["call/".concat(callId, "/users/join"), payload, headers]);
|
|
119
|
-
expect(response).toEqual(joinCallResponse);
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); });
|
|
124
|
-
it('should join a call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
-
var _a, client, headers, postCall, response;
|
|
126
|
-
return __generator(this, function (_b) {
|
|
127
|
-
switch (_b.label) {
|
|
128
|
-
case 0:
|
|
129
|
-
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
130
|
-
postCall = sinon_1.default.stub(httpClient, 'post').resolves(joinCallResponse);
|
|
131
|
-
return [4 /*yield*/, client.joinCall(callId, payload)];
|
|
132
|
-
case 1:
|
|
133
|
-
response = _b.sent();
|
|
134
|
-
// Assert
|
|
135
|
-
expect(postCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users/join"));
|
|
136
|
-
expect(postCall.firstCall.args[1]).toEqual(payload);
|
|
137
|
-
expect(postCall.firstCall.args[2]).toEqual(headers);
|
|
138
|
-
expect(response).toEqual(joinCallResponse);
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}); });
|
|
143
|
-
});
|
|
144
|
-
describe('getCurrentUsersInCall method', function () {
|
|
145
|
-
var callId = 'call-123';
|
|
146
|
-
var usersInCallResponse = [
|
|
147
|
-
{
|
|
148
|
-
userId: 'user-123',
|
|
149
|
-
name: 'John',
|
|
150
|
-
lastname: 'Doe',
|
|
151
|
-
anonymous: false,
|
|
152
|
-
avatar: 'avatar-url-1',
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
userId: 'user-456',
|
|
156
|
-
name: 'Jane',
|
|
157
|
-
lastname: 'Smith',
|
|
158
|
-
anonymous: true,
|
|
159
|
-
avatar: 'avatar-url-2',
|
|
160
|
-
},
|
|
161
|
-
];
|
|
162
|
-
it('should get current users in call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
163
|
-
var _a, client, headers, getCall, response;
|
|
164
|
-
return __generator(this, function (_b) {
|
|
165
|
-
switch (_b.label) {
|
|
166
|
-
case 0:
|
|
167
|
-
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
168
|
-
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
169
|
-
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
170
|
-
case 1:
|
|
171
|
-
response = _b.sent();
|
|
172
|
-
// Assert
|
|
173
|
-
expect(getCall.firstCall.args).toEqual(["call/".concat(callId, "/users"), headers]);
|
|
174
|
-
expect(response).toEqual(usersInCallResponse);
|
|
175
|
-
return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}); });
|
|
179
|
-
it('should get current users in call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
180
|
-
var _a, client, headers, getCall, response;
|
|
181
|
-
return __generator(this, function (_b) {
|
|
182
|
-
switch (_b.label) {
|
|
183
|
-
case 0:
|
|
184
|
-
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
185
|
-
getCall = sinon_1.default.stub(httpClient, 'get').resolves(usersInCallResponse);
|
|
186
|
-
return [4 /*yield*/, client.getCurrentUsersInCall(callId)];
|
|
187
|
-
case 1:
|
|
188
|
-
response = _b.sent();
|
|
189
|
-
// Assert
|
|
190
|
-
expect(getCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users"));
|
|
191
|
-
expect(getCall.firstCall.args[1]).toEqual(headers);
|
|
192
|
-
expect(response).toEqual(usersInCallResponse);
|
|
193
|
-
return [2 /*return*/];
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}); });
|
|
197
|
-
});
|
|
198
|
-
describe('leaveCall method', function () {
|
|
199
|
-
var callId = 'call-123';
|
|
200
|
-
it('should leave a call successfully with token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
201
|
-
var _a, client, headers, postCall;
|
|
202
|
-
return __generator(this, function (_b) {
|
|
203
|
-
switch (_b.label) {
|
|
204
|
-
case 0:
|
|
205
|
-
_a = clientAndHeadersWithToken(), client = _a.client, headers = _a.headers;
|
|
206
|
-
postCall = sinon_1.default.stub(httpClient, 'post').resolves();
|
|
207
|
-
// Act
|
|
208
|
-
return [4 /*yield*/, client.leaveCall(callId)];
|
|
209
|
-
case 1:
|
|
210
|
-
// Act
|
|
211
|
-
_b.sent();
|
|
212
|
-
// Assert
|
|
213
|
-
expect(postCall.firstCall.args).toEqual(["call/".concat(callId, "/users/leave"), {}, headers]);
|
|
214
|
-
return [2 /*return*/];
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
}); });
|
|
218
|
-
it('should leave a call successfully without token', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
219
|
-
var _a, client, headers, postCall;
|
|
220
|
-
return __generator(this, function (_b) {
|
|
221
|
-
switch (_b.label) {
|
|
222
|
-
case 0:
|
|
223
|
-
_a = clientAndHeadersWithoutToken(), client = _a.client, headers = _a.headers;
|
|
224
|
-
postCall = sinon_1.default.stub(httpClient, 'post').resolves();
|
|
225
|
-
// Act
|
|
226
|
-
return [4 /*yield*/, client.leaveCall(callId)];
|
|
227
|
-
case 1:
|
|
228
|
-
// Act
|
|
229
|
-
_b.sent();
|
|
230
|
-
// Assert
|
|
231
|
-
expect(postCall.firstCall.args[0]).toEqual("call/".concat(callId, "/users/leave"));
|
|
232
|
-
expect(postCall.firstCall.args[1]).toEqual({});
|
|
233
|
-
expect(postCall.firstCall.args[2]).toEqual(headers);
|
|
234
|
-
return [2 /*return*/];
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}); });
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
function clientAndHeadersWithToken(apiUrl, clientName, clientVersion, token) {
|
|
241
|
-
if (apiUrl === void 0) { apiUrl = ''; }
|
|
242
|
-
if (clientName === void 0) { clientName = 'c-name'; }
|
|
243
|
-
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
244
|
-
if (token === void 0) { token = 'my-token'; }
|
|
245
|
-
var appDetails = {
|
|
246
|
-
clientName: clientName,
|
|
247
|
-
clientVersion: clientVersion,
|
|
248
|
-
};
|
|
249
|
-
var apiSecurity = {
|
|
250
|
-
token: token,
|
|
251
|
-
};
|
|
252
|
-
var client = index_1.Meet.client(apiUrl, appDetails, apiSecurity);
|
|
253
|
-
var headers = (0, headers_1.headersWithToken)({ clientName: clientName, clientVersion: clientVersion, token: token });
|
|
254
|
-
return { client: client, headers: headers };
|
|
255
|
-
}
|
|
256
|
-
function clientAndHeadersWithoutToken(apiUrl, clientName, clientVersion) {
|
|
257
|
-
if (apiUrl === void 0) { apiUrl = ''; }
|
|
258
|
-
if (clientName === void 0) { clientName = 'c-name'; }
|
|
259
|
-
if (clientVersion === void 0) { clientVersion = '0.1'; }
|
|
260
|
-
var appDetails = {
|
|
261
|
-
clientName: clientName,
|
|
262
|
-
clientVersion: clientVersion,
|
|
263
|
-
};
|
|
264
|
-
var client = index_1.Meet.client(apiUrl, appDetails);
|
|
265
|
-
var headers = (0, headers_1.basicHeaders)({ clientName: clientName, clientVersion: clientVersion });
|
|
266
|
-
return { client: client, headers: headers };
|
|
267
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|