@wazo/sdk 0.45.0 → 0.45.2
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/index.js +22 -5
- package/dist/index.mjs +22 -5
- package/dist/types/utils/api-requester.d.ts +15 -2
- package/dist/types/utils/api-requester.d.ts.map +1 -1
- package/dist/wazo-sdk.js +22 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -632,9 +632,19 @@ class ApiRequester {
|
|
|
632
632
|
if (token) this.token = token;
|
|
633
633
|
this.shouldLogErrors = true;
|
|
634
634
|
methods.forEach((method)=>{
|
|
635
|
-
this[method] =
|
|
636
|
-
|
|
637
|
-
|
|
635
|
+
this[method] = (pathOrParams, body, headers, parse, firstCall)=>{
|
|
636
|
+
if (pathOrParams && 'object' == typeof pathOrParams && pathOrParams.path) return this.call({
|
|
637
|
+
...pathOrParams,
|
|
638
|
+
method
|
|
639
|
+
});
|
|
640
|
+
return this.call({
|
|
641
|
+
path: pathOrParams,
|
|
642
|
+
method,
|
|
643
|
+
body,
|
|
644
|
+
headers,
|
|
645
|
+
parse,
|
|
646
|
+
firstCall
|
|
647
|
+
});
|
|
638
648
|
};
|
|
639
649
|
});
|
|
640
650
|
}
|
|
@@ -656,7 +666,7 @@ class ApiRequester {
|
|
|
656
666
|
enableErrorLogging() {
|
|
657
667
|
this.shouldLogErrors = true;
|
|
658
668
|
}
|
|
659
|
-
async call(path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true) {
|
|
669
|
+
async call({ path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true }) {
|
|
660
670
|
const url = this.computeUrl(method, path, body);
|
|
661
671
|
const newHeaders = this.getHeaders(headers);
|
|
662
672
|
let newBody = 'get' === method ? null : body;
|
|
@@ -753,7 +763,14 @@ class ApiRequester {
|
|
|
753
763
|
pathParts.push(this.token);
|
|
754
764
|
newPath = pathParts.join('/');
|
|
755
765
|
}
|
|
756
|
-
return this.call(
|
|
766
|
+
return this.call({
|
|
767
|
+
path: newPath,
|
|
768
|
+
method,
|
|
769
|
+
body,
|
|
770
|
+
headers,
|
|
771
|
+
parse,
|
|
772
|
+
firstCall: false
|
|
773
|
+
});
|
|
757
774
|
}).catch((e)=>{
|
|
758
775
|
this.refreshTokenPromise = null;
|
|
759
776
|
throw e;
|
package/dist/index.mjs
CHANGED
|
@@ -572,9 +572,19 @@ class ApiRequester {
|
|
|
572
572
|
if (token) this.token = token;
|
|
573
573
|
this.shouldLogErrors = true;
|
|
574
574
|
methods.forEach((method)=>{
|
|
575
|
-
this[method] =
|
|
576
|
-
|
|
577
|
-
|
|
575
|
+
this[method] = (pathOrParams, body, headers, parse, firstCall)=>{
|
|
576
|
+
if (pathOrParams && 'object' == typeof pathOrParams && pathOrParams.path) return this.call({
|
|
577
|
+
...pathOrParams,
|
|
578
|
+
method
|
|
579
|
+
});
|
|
580
|
+
return this.call({
|
|
581
|
+
path: pathOrParams,
|
|
582
|
+
method,
|
|
583
|
+
body,
|
|
584
|
+
headers,
|
|
585
|
+
parse,
|
|
586
|
+
firstCall
|
|
587
|
+
});
|
|
578
588
|
};
|
|
579
589
|
});
|
|
580
590
|
}
|
|
@@ -596,7 +606,7 @@ class ApiRequester {
|
|
|
596
606
|
enableErrorLogging() {
|
|
597
607
|
this.shouldLogErrors = true;
|
|
598
608
|
}
|
|
599
|
-
async call(path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true) {
|
|
609
|
+
async call({ path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true }) {
|
|
600
610
|
const url = this.computeUrl(method, path, body);
|
|
601
611
|
const newHeaders = this.getHeaders(headers);
|
|
602
612
|
let newBody = 'get' === method ? null : body;
|
|
@@ -693,7 +703,14 @@ class ApiRequester {
|
|
|
693
703
|
pathParts.push(this.token);
|
|
694
704
|
newPath = pathParts.join('/');
|
|
695
705
|
}
|
|
696
|
-
return this.call(
|
|
706
|
+
return this.call({
|
|
707
|
+
path: newPath,
|
|
708
|
+
method,
|
|
709
|
+
body,
|
|
710
|
+
headers,
|
|
711
|
+
parse,
|
|
712
|
+
firstCall: false
|
|
713
|
+
});
|
|
697
714
|
}).catch((e)=>{
|
|
698
715
|
this.refreshTokenPromise = null;
|
|
699
716
|
throw e;
|
|
@@ -7,6 +7,7 @@ type ConstructorParams = {
|
|
|
7
7
|
fetchOptions: Record<string, any> | null | undefined;
|
|
8
8
|
requestTimeout?: number | null;
|
|
9
9
|
};
|
|
10
|
+
type Methods = 'head' | 'get' | 'post' | 'put' | 'delete' | 'options';
|
|
10
11
|
type CallMethod = 'head' | 'get' | 'post' | 'put' | 'delete' | 'options';
|
|
11
12
|
type CallBody = Record<string, any> | null | undefined | string;
|
|
12
13
|
type CallHeaders = {
|
|
@@ -14,7 +15,17 @@ type CallHeaders = {
|
|
|
14
15
|
[key: string]: any;
|
|
15
16
|
} | null | undefined;
|
|
16
17
|
type CallParser = ((...args: Array<any>) => any) | undefined;
|
|
17
|
-
type
|
|
18
|
+
type CallParams = {
|
|
19
|
+
path: string;
|
|
20
|
+
body?: CallBody;
|
|
21
|
+
headers?: CallHeaders;
|
|
22
|
+
parse?: CallParser;
|
|
23
|
+
firstCall?: boolean;
|
|
24
|
+
};
|
|
25
|
+
type CallHelpers = {
|
|
26
|
+
(options: CallParams): Promise<any>;
|
|
27
|
+
(path: string, body?: CallBody, headers?: CallHeaders, parse?: CallParser, firstCall?: boolean): Promise<any>;
|
|
28
|
+
};
|
|
18
29
|
export default class ApiRequester {
|
|
19
30
|
server: string;
|
|
20
31
|
agent: Record<string, any> | null | undefined;
|
|
@@ -43,7 +54,9 @@ export default class ApiRequester {
|
|
|
43
54
|
setFetchOptions(options: Record<string, any>): void;
|
|
44
55
|
disableErrorLogging(): void;
|
|
45
56
|
enableErrorLogging(): void;
|
|
46
|
-
call(path
|
|
57
|
+
call({ path, method, body, headers, parse, firstCall, }: CallParams & {
|
|
58
|
+
method: Methods;
|
|
59
|
+
}): Promise<any>;
|
|
47
60
|
_checkTokenExpired(response: Record<string, any>, err: Record<string, any>): any;
|
|
48
61
|
_isTokenNotFound(err: Record<string, any>): any;
|
|
49
62
|
_replayWithNewToken(err: Record<string, any>, path: string, method: CallMethod, body?: CallBody, headers?: CallHeaders, parse?: CallParser): Promise<any> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-requester.d.ts","sourceRoot":"","sources":["../../../src/utils/api-requester.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,oBAAoB,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACrD,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"api-requester.d.ts","sourceRoot":"","sources":["../../../src/utils/api-requester.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACpC,oBAAoB,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;IACnD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,EAAE,MA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,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAI3C,QAAQ,CAAC,KAAK,EAAE,MAAM;IAItB,eAAe,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAI5C,mBAAmB;IAInB,kBAAkB;IAIZ,IAAI,CAAC,EACT,IAAI,EACJ,MAAc,EACd,IAAW,EACX,OAAc,EACd,KAAkC,EAClC,SAAgB,GACjB,EAAE,UAAU,GAAG;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAyFlD,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAO1E,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAIzC,mBAAmB,CACjB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,QAAe,EACrB,OAAO,GAAE,WAAkB,EAC3B,KAAK,GAAE,UAAsB;IA6B/B,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAwBpD,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM;IAKpE,IAAI,OAAO,IAAI,MAAM,CAEpB;CAEF"}
|
package/dist/wazo-sdk.js
CHANGED
|
@@ -33980,9 +33980,19 @@
|
|
|
33980
33980
|
if (token) this.token = token;
|
|
33981
33981
|
this.shouldLogErrors = true;
|
|
33982
33982
|
methods.forEach((method)=>{
|
|
33983
|
-
this[method] =
|
|
33984
|
-
|
|
33985
|
-
|
|
33983
|
+
this[method] = (pathOrParams, body, headers, parse, firstCall)=>{
|
|
33984
|
+
if (pathOrParams && 'object' == typeof pathOrParams && pathOrParams.path) return this.call({
|
|
33985
|
+
...pathOrParams,
|
|
33986
|
+
method
|
|
33987
|
+
});
|
|
33988
|
+
return this.call({
|
|
33989
|
+
path: pathOrParams,
|
|
33990
|
+
method,
|
|
33991
|
+
body,
|
|
33992
|
+
headers,
|
|
33993
|
+
parse,
|
|
33994
|
+
firstCall
|
|
33995
|
+
});
|
|
33986
33996
|
};
|
|
33987
33997
|
});
|
|
33988
33998
|
}
|
|
@@ -34004,7 +34014,7 @@
|
|
|
34004
34014
|
enableErrorLogging() {
|
|
34005
34015
|
this.shouldLogErrors = true;
|
|
34006
34016
|
}
|
|
34007
|
-
async call(path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true) {
|
|
34017
|
+
async call({ path, method = 'get', body = null, headers = null, parse = ApiRequester.defaultParser, firstCall = true }) {
|
|
34008
34018
|
const url = this.computeUrl(method, path, body);
|
|
34009
34019
|
const newHeaders = this.getHeaders(headers);
|
|
34010
34020
|
let newBody = 'get' === method ? null : body;
|
|
@@ -34101,7 +34111,14 @@
|
|
|
34101
34111
|
pathParts.push(this.token);
|
|
34102
34112
|
newPath = pathParts.join('/');
|
|
34103
34113
|
}
|
|
34104
|
-
return this.call(
|
|
34114
|
+
return this.call({
|
|
34115
|
+
path: newPath,
|
|
34116
|
+
method,
|
|
34117
|
+
body,
|
|
34118
|
+
headers,
|
|
34119
|
+
parse,
|
|
34120
|
+
firstCall: false
|
|
34121
|
+
});
|
|
34105
34122
|
}).catch((e)=>{
|
|
34106
34123
|
this.refreshTokenPromise = null;
|
|
34107
34124
|
throw e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wazo/sdk",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.2",
|
|
4
4
|
"description": "Wazo's JavaScript Software Development Kit.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/wazo-platform/wazo-js-sdk/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@wazo/types": "^25.
|
|
33
|
+
"@wazo/types": "^25.8.0",
|
|
34
34
|
"events": "^3.3.0",
|
|
35
35
|
"fstream": "^1.0.12",
|
|
36
36
|
"getstats": "wazo-platform/getStats#1.0.7",
|