bx-rest 0.6.8 → 0.8.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/esm2022/map/pull.mjs +12 -10
- package/esm2022/map/user.mjs +1 -1
- package/esm2022/public-api.mjs +2 -2
- package/esm2022/request/user.mjs +1 -1
- package/esm2022/request-navvy/pull/config.mjs +5 -1
- package/esm2022/request-navvy/task/operation/elapseditem.mjs +1 -1
- package/esm2022/request-navvy/timeman.mjs +30 -18
- package/esm2022/request-navvy/user.mjs +1 -1
- package/esm2022/services/base.mjs +4 -4
- package/esm2022/services/http/HttpBX.mjs +38 -4
- package/esm2022/services/http/HttpData.mjs +2 -2
- package/esm2022/services/http/http.mjs +25 -1
- package/esm2022/services/http/httpNavvy.mjs +1 -1
- package/esm2022/services/http/sessionKey.mjs +6 -2
- package/esm2022/typification/base.mjs +5 -0
- package/esm2022/typification/rest/base.mjs +5 -0
- package/esm2022/typification/rest/timeman/status.mjs +1 -1
- package/esm2022/typification/rest/user/userFilter.mjs +2 -0
- package/esm2022/typification/rest/user.mjs +8 -0
- package/esm2022/typification/settings.mjs +1 -1
- package/fesm2022/bx-rest.mjs +113 -33
- package/fesm2022/bx-rest.mjs.map +1 -1
- package/map/user.d.ts +1 -1
- package/package.json +17 -11
- package/public-api.d.ts +1 -1
- package/request/app.d.ts +1 -1
- package/request/bizproc/workflow.d.ts +1 -1
- package/request/department.d.ts +4 -4
- package/request/disk/attachedObject.d.ts +1 -1
- package/request/disk/file.d.ts +2 -2
- package/request/disk/folder.d.ts +12 -12
- package/request/disk/storage.d.ts +4 -4
- package/request/lists/element.d.ts +2 -2
- package/request/lists/field.d.ts +1 -1
- package/request/lists.d.ts +1 -1
- package/request/log/blogpost.d.ts +2 -2
- package/request/pull/application/config.d.ts +1 -1
- package/request/pull/channel/public.d.ts +1 -1
- package/request/pull/config.d.ts +1 -1
- package/request/server.d.ts +1 -1
- package/request/socialnetwork/api/contentview.d.ts +1 -1
- package/request/socialnetwork/api/livefeed/blogpost/important.d.ts +1 -1
- package/request/sonet_group.d.ts +1 -1
- package/request/task/commentitem.d.ts +5 -5
- package/request/task/elapseditem.d.ts +5 -5
- package/request/task/item/userfield.d.ts +1 -1
- package/request/task/planner.d.ts +1 -1
- package/request/tasks/task/result.d.ts +3 -3
- package/request/tasks/task.d.ts +9 -9
- package/request/timeman.d.ts +1 -1
- package/request/user/userfield.d.ts +1 -1
- package/request/user.d.ts +10 -10
- package/request-navvy/pull/config.d.ts +4 -0
- package/request-navvy/task/operation/elapseditem.d.ts +1 -1
- package/request-navvy/timeman.d.ts +22 -2
- package/request-navvy/user.d.ts +3 -3
- package/rest/base.d.ts +2 -2
- package/services/http/HttpBX.d.ts +1 -0
- package/services/http/httpNavvy.d.ts +1 -1
- package/typification/base.d.ts +4 -0
- package/typification/rest/base.d.ts +4 -0
- package/typification/rest/timeman/status.d.ts +76 -1
- package/typification/rest/user/userFilter.d.ts +13 -0
- package/typification/rest/user.d.ts +7 -0
- package/typification/settings.d.ts +2 -2
package/fesm2022/bx-rest.mjs
CHANGED
|
@@ -269,9 +269,9 @@ async function getBase64FileLikeStr(file) {
|
|
|
269
269
|
return undefined;
|
|
270
270
|
}
|
|
271
271
|
function prepareBaseAddress(url, add = '') {
|
|
272
|
-
if (url.search('https://') !== 0 && url.search('http://')) {
|
|
273
|
-
|
|
274
|
-
}
|
|
272
|
+
// if (url.search('https://') !== 0 && url.search('http://')) {
|
|
273
|
+
// url = 'https://' + url
|
|
274
|
+
// }
|
|
275
275
|
if (add && add.length > 0) {
|
|
276
276
|
if (url.lastIndexOf('/') !== (url.length - 1)) {
|
|
277
277
|
url = url + '/';
|
|
@@ -424,7 +424,11 @@ class SessionKeyServices {
|
|
|
424
424
|
return '';
|
|
425
425
|
}
|
|
426
426
|
getAuthParams() {
|
|
427
|
-
|
|
427
|
+
const source = this.BX_REST_SETTINGS.auth.source;
|
|
428
|
+
if (typeof source === 'function') {
|
|
429
|
+
return source();
|
|
430
|
+
}
|
|
431
|
+
switch (source) {
|
|
428
432
|
case 'cookies':
|
|
429
433
|
return this.getAuth();
|
|
430
434
|
case 'localStorage':
|
|
@@ -506,7 +510,7 @@ class HttpData {
|
|
|
506
510
|
case 'function':
|
|
507
511
|
case 'undefined':
|
|
508
512
|
default:
|
|
509
|
-
console.error('
|
|
513
|
+
console.error('You sent something wrong', obj[key], typeof obj[key], typeof obj);
|
|
510
514
|
}
|
|
511
515
|
}
|
|
512
516
|
}
|
|
@@ -544,6 +548,30 @@ class HttpServices extends BaseHttp {
|
|
|
544
548
|
return throwError(() => new Error('get base url error'));
|
|
545
549
|
}
|
|
546
550
|
const fullUrl = prepareBaseAddress(baseUrl) + url;
|
|
551
|
+
if (this.session.getKeyAuth() === 'sessid') {
|
|
552
|
+
const body = this.getHttpParamsPost(paramsClone, new FormData(), [], settings);
|
|
553
|
+
// Преобразуем параметры в формат x-www-form-urlencoded
|
|
554
|
+
const urlEncodedBody = new URLSearchParams();
|
|
555
|
+
Object.keys(body).forEach((key) => {
|
|
556
|
+
const value = paramsClone[key];
|
|
557
|
+
// если value — объект или массив, Bitrix ожидает fields[key] или array[] формат
|
|
558
|
+
if (typeof value === 'object' && value !== null) {
|
|
559
|
+
for (const subKey in value) {
|
|
560
|
+
if (Object.prototype.hasOwnProperty.call(value, subKey)) {
|
|
561
|
+
urlEncodedBody.append(`${key}[${subKey}]`, value[subKey]);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
else {
|
|
566
|
+
urlEncodedBody.append(key, value);
|
|
567
|
+
}
|
|
568
|
+
});
|
|
569
|
+
return from(this.axiosInstance.post(fullUrl, urlEncodedBody.toString(), {
|
|
570
|
+
headers: {
|
|
571
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
572
|
+
},
|
|
573
|
+
}).then((response) => response.data));
|
|
574
|
+
}
|
|
547
575
|
const body = this.getHttpParamsPost(paramsClone, new FormData(), [], settings);
|
|
548
576
|
return from(this.axiosInstance.post(fullUrl, body).then((response) => response.data));
|
|
549
577
|
}));
|
|
@@ -636,27 +664,61 @@ class HttpBXServices extends HttpServices {
|
|
|
636
664
|
}
|
|
637
665
|
httpPost(url, params = {}) {
|
|
638
666
|
const paramsClone = clone(params);
|
|
667
|
+
const key = this.session.getKeyAuth();
|
|
639
668
|
let auth = this.session.getAuthParams();
|
|
640
669
|
const checkIsOn = this.session.getCheckAuthParamsIsOn();
|
|
641
|
-
if (checkIsOn) {
|
|
670
|
+
if (checkIsOn && key === 'OAuth2') {
|
|
642
671
|
if (!auth && BXRestSettings.date.auth.source !== 'off') {
|
|
643
672
|
throw new Error('Authorization required (post)');
|
|
644
673
|
}
|
|
645
|
-
paramsClone[
|
|
674
|
+
paramsClone[key] = auth;
|
|
646
675
|
}
|
|
647
676
|
return this.session.getBaseUrl().pipe(switchMap((baseUrl) => {
|
|
648
677
|
if (!baseUrl) {
|
|
649
678
|
return throwError(() => new Error('get base url error'));
|
|
650
679
|
}
|
|
651
680
|
const fullUrl = prepareBaseAddress(baseUrl) + url;
|
|
652
|
-
|
|
681
|
+
if (auth === 'sessid') {
|
|
682
|
+
// Преобразуем параметры в формат x-www-form-urlencoded
|
|
683
|
+
const bodyString = this.serializeBitrixParams(paramsClone);
|
|
684
|
+
return from(this.axiosInstance.post(fullUrl, bodyString, {
|
|
685
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
686
|
+
}).then((response) => response.data));
|
|
687
|
+
}
|
|
653
688
|
return from(this.axiosInstance.post(fullUrl, paramsClone, {
|
|
689
|
+
withCredentials: key === 'OAuth2',
|
|
654
690
|
headers: {
|
|
655
691
|
'Content-Type': 'application/json',
|
|
656
692
|
}
|
|
657
693
|
}).then((response) => response.data));
|
|
658
694
|
}));
|
|
659
695
|
}
|
|
696
|
+
serializeBitrixParams(obj, prefix = '') {
|
|
697
|
+
const pairs = [];
|
|
698
|
+
for (const key in obj) {
|
|
699
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key))
|
|
700
|
+
continue;
|
|
701
|
+
const value = obj[key];
|
|
702
|
+
const prefixedKey = prefix ? `${prefix}[${key}]` : key;
|
|
703
|
+
if (Array.isArray(value)) {
|
|
704
|
+
value.forEach((item) => {
|
|
705
|
+
if (typeof item === 'object') {
|
|
706
|
+
pairs.push(this.serializeBitrixParams(item, `${prefixedKey}[]`));
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
pairs.push(`${encodeURIComponent(prefixedKey)}[]=${encodeURIComponent(item)}`);
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
else if (typeof value === 'object' && value !== null) {
|
|
714
|
+
pairs.push(this.serializeBitrixParams(value, prefixedKey));
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
pairs.push(`${encodeURIComponent(prefixedKey)}=${encodeURIComponent(value)}`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
return pairs.join('&');
|
|
721
|
+
}
|
|
660
722
|
// Мб не работает
|
|
661
723
|
httpGet(url, params = {}) {
|
|
662
724
|
if (params === null) {
|
|
@@ -5890,26 +5952,26 @@ class BXRestMapTimeMan {
|
|
|
5890
5952
|
class BXRestNavvyTimeMan {
|
|
5891
5953
|
constructor() {
|
|
5892
5954
|
this.url = {
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5955
|
+
/**
|
|
5956
|
+
* Получение настроек рабочего времени пользователя
|
|
5957
|
+
*/
|
|
5958
|
+
settings: [$timeMan, $settings],
|
|
5897
5959
|
/**
|
|
5898
5960
|
* Получение информации о текущем рабочем дне пользователя
|
|
5899
5961
|
*/
|
|
5900
5962
|
status: [$timeMan, $status],
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
|
|
5906
|
-
|
|
5907
|
-
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5963
|
+
/**
|
|
5964
|
+
* Начать новый рабочий день либо возобновить закрытый или приостановленный
|
|
5965
|
+
*/
|
|
5966
|
+
open: [$timeMan, 'open'],
|
|
5967
|
+
/**
|
|
5968
|
+
* Закрыть рабочий день
|
|
5969
|
+
*/
|
|
5970
|
+
close: [$timeMan, 'close'],
|
|
5971
|
+
/**
|
|
5972
|
+
* Приостановить рабочий день
|
|
5973
|
+
*/
|
|
5974
|
+
pause: [$timeMan, $pause],
|
|
5913
5975
|
// networkrange: {
|
|
5914
5976
|
// check: this.baseUrl + 'networkrange.check', // Метод для проверки IP-адреса на вхождение в диапазоны сетевых адресов офисной сети
|
|
5915
5977
|
// get: this.baseUrl + 'networkrange.get', // Метод для получения диапазонов сетевых адресов, входящих в офисную сеть
|
|
@@ -5940,6 +6002,18 @@ class BXRestNavvyTimeMan {
|
|
|
5940
6002
|
status(param = undefined) {
|
|
5941
6003
|
return this.Navvy.simple(this.url.status, param, BXRestMapTimeMan.status);
|
|
5942
6004
|
}
|
|
6005
|
+
open(param = {}) {
|
|
6006
|
+
return this.Navvy.simple(this.url.open, param, BXRestMapTimeMan.status);
|
|
6007
|
+
}
|
|
6008
|
+
pause(param = {}) {
|
|
6009
|
+
return this.Navvy.simple(this.url.pause, param, BXRestMapTimeMan.status);
|
|
6010
|
+
}
|
|
6011
|
+
close(param = {}) {
|
|
6012
|
+
return this.Navvy.simple(this.url.close, param, BXRestMapTimeMan.status);
|
|
6013
|
+
}
|
|
6014
|
+
settings(param = {}) {
|
|
6015
|
+
return this.Navvy.simple(this.url.settings, param);
|
|
6016
|
+
}
|
|
5943
6017
|
}
|
|
5944
6018
|
|
|
5945
6019
|
class BXRestNavvySocialNetWorkApiContentView {
|
|
@@ -6035,15 +6109,17 @@ class BXRestMapPullApplicationConfig {
|
|
|
6035
6109
|
|
|
6036
6110
|
class BXRestMapPull {
|
|
6037
6111
|
static get(value) {
|
|
6038
|
-
console.log('Object.entries(value.publicChannels)', value)
|
|
6039
|
-
if
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
}
|
|
6112
|
+
// console.log('Object.entries(value.publicChannels)', value)
|
|
6113
|
+
//if(value?.publicChannels) {
|
|
6114
|
+
// console.log('Object.entries(value.publicChannels)',
|
|
6115
|
+
// value.publicChannels, Object.entries(value.publicChannels), Object.fromEntries(Object.entries(value.publicChannels).map(([key, val]) => (
|
|
6116
|
+
// [key,
|
|
6117
|
+
// {
|
|
6118
|
+
// ...val,
|
|
6119
|
+
// start: toDate(val.start), end: toDate(val.end)
|
|
6120
|
+
// } as iBXRestPullConfigPublicChannelsGet
|
|
6121
|
+
// ]))) as Record<string, iBXRestPullConfigPublicChannelsGet>,)
|
|
6122
|
+
//}
|
|
6047
6123
|
return value ? { ...BXRestMapPullApplicationConfig.get(value), ...{ serverTime: toDate(value.serverTime) } } : undefined;
|
|
6048
6124
|
}
|
|
6049
6125
|
}
|
|
@@ -6070,6 +6146,10 @@ class BXRestNavvyPullConfig {
|
|
|
6070
6146
|
this.Navvy = new Navvy();
|
|
6071
6147
|
}
|
|
6072
6148
|
static { this.public = new BXRestMapPullChannelPublic(); }
|
|
6149
|
+
/**
|
|
6150
|
+
* @experimental
|
|
6151
|
+
* Этот метод находится в процессе тестирования и может измениться.
|
|
6152
|
+
*/
|
|
6073
6153
|
get() {
|
|
6074
6154
|
return this.Navvy.simple(this.url.get, undefined, BXRestMapPull.get);
|
|
6075
6155
|
}
|