bx-rest 0.21.1 → 0.21.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/README.md +35 -4
- package/esm2022/functions/errors.mjs +17 -0
- package/esm2022/public-api.mjs +2 -1
- package/esm2022/services/navvy/extends/navvy-pag-base.mjs +14 -5
- package/fesm2022/bx-rest.mjs +30 -5
- package/fesm2022/bx-rest.mjs.map +1 -1
- package/functions/errors.d.ts +13 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
- package/services/navvy/extends/navvy-pag-base.d.ts +13 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown by `.res()` when called with `{ throwOnApiError: true }` and the
|
|
3
|
+
* Bitrix REST call resolves as a Bitrix-level API error, e.g.
|
|
4
|
+
* `INSUFFICIENT_SCOPE` or `expired_token`.
|
|
5
|
+
*
|
|
6
|
+
* By default `.res()` resolves such responses as `undefined` instead of
|
|
7
|
+
* throwing — see the "Error handling" section of the README.
|
|
8
|
+
*/
|
|
9
|
+
export declare class BXRestApiError extends Error {
|
|
10
|
+
error: string | undefined;
|
|
11
|
+
error_description: string | undefined;
|
|
12
|
+
constructor(error: string | undefined, error_description: string | undefined);
|
|
13
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { Navvy } from './services/navvy';
|
|
|
9
9
|
export { HttpBXServices as BXRestRequest } from './services/http/HttpBX';
|
|
10
10
|
export { SessionKeyServices, SessionKeyError } from './services/http/sessionKey';
|
|
11
11
|
export { instanceOfiBXRestAnswerSuccess as isBXRestAnswerSuccess } from './functions/mapResult';
|
|
12
|
+
export { BXRestApiError } from './functions/errors';
|
|
13
|
+
export { BXRestResOptions } from './services/navvy/extends/navvy-pag-base';
|
|
12
14
|
export { HttpNavvyServices } from './services/http/httpNavvy';
|
|
13
15
|
export * as partNameMethods from './consts/part-name-methods';
|
|
14
16
|
export * as BXBaseServices from './services/base';
|
|
@@ -2,6 +2,17 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { iBXRestAnswer } from '../../../typification/rest/base/answer';
|
|
3
3
|
import { HttpBXServices } from '../../http/HttpBX';
|
|
4
4
|
import { ReturnTypeNavvy } from '../navvy-support';
|
|
5
|
+
export interface BXRestResOptions {
|
|
6
|
+
/**
|
|
7
|
+
* When `true`, a Bitrix-level API error (`{ error, error_description }`,
|
|
8
|
+
* e.g. `INSUFFICIENT_SCOPE`, `expired_token`) makes the `Observable`
|
|
9
|
+
* returned by `.res()` error out with a `BXRestApiError` instead of
|
|
10
|
+
* resolving with `undefined`.
|
|
11
|
+
*
|
|
12
|
+
* Default: `false` (preserves the historical `.res()` behaviour).
|
|
13
|
+
*/
|
|
14
|
+
throwOnApiError?: boolean;
|
|
15
|
+
}
|
|
5
16
|
export declare abstract class NavvyPagBase<T, R, P> {
|
|
6
17
|
protected url: string[];
|
|
7
18
|
protected param: P;
|
|
@@ -12,6 +23,6 @@ export declare abstract class NavvyPagBase<T, R, P> {
|
|
|
12
23
|
constructor(url: string[], param: P, map?: ((param: T | undefined) => R | undefined) | undefined, restApi?: boolean);
|
|
13
24
|
resVanilla(): Observable<iBXRestAnswer<T> | undefined>;
|
|
14
25
|
mapForVanilla(): Observable<iBXRestAnswer<ReturnTypeNavvy<T, R>> | undefined>;
|
|
15
|
-
res(): Observable<ReturnTypeNavvy<T, R> | undefined>;
|
|
16
|
-
mapAndError<T>(request: Observable<iBXRestAnswer<T> | undefined
|
|
26
|
+
res(options?: BXRestResOptions): Observable<ReturnTypeNavvy<T, R> | undefined>;
|
|
27
|
+
mapAndError<T>(request: Observable<iBXRestAnswer<T> | undefined>, options?: BXRestResOptions): Observable<T | undefined>;
|
|
17
28
|
}
|