bx-rest 0.0.11 → 0.0.13

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.
@@ -1,12 +1,24 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
- import { Injectable } from '@angular/core';
3
+ import { Injectable, NgModule, inject, Component, ViewEncapsulation, Inject } from '@angular/core';
4
4
  import { DateTime } from 'luxon';
5
- import { take, of } from 'rxjs';
6
- import { tap, map, mergeMap, first } from 'rxjs/operators';
5
+ import { Subscription, filter, take, of, throwError, forkJoin, mergeMap } from 'rxjs';
6
+ import { map, catchError, tap, mergeMap as mergeMap$1, first } from 'rxjs/operators';
7
7
  import clone from 'just-clone';
8
8
  import compare from 'just-compare';
9
+ import * as i1$1 from '@angular/material/snack-bar';
10
+ import { MatSnackBarRef, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
11
+ import * as i2 from '@angular/material/icon';
12
+ import { MatIconModule } from '@angular/material/icon';
13
+ import * as i1 from '@angular/material/button';
14
+ import { MatButtonModule } from '@angular/material/button';
15
+ import * as i1$2 from '@ngrx/store';
9
16
  import { createAction, props, createReducer, on } from '@ngrx/store';
17
+ import * as i2$1 from '@angular/router';
18
+ import flatten from 'just-flatten-it';
19
+ import * as i1$3 from '@angular/common/http';
20
+ import { HttpParams } from '@angular/common/http';
21
+ import * as i3 from '@angular/common';
10
22
 
11
23
  const time = {
12
24
  oneDayMilliseconds: 1000 * 60 * 60 * 24
@@ -183,6 +195,1009 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImpor
183
195
  }]
184
196
  }] });
185
197
 
198
+ class BxRestModule {
199
+ }
200
+ BxRestModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
201
+ BxRestModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, imports: [MatIconModule,
202
+ MatButtonModule], exports: [MatButtonModule,
203
+ MatIconModule] });
204
+ BxRestModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, imports: [MatIconModule,
205
+ MatButtonModule, MatButtonModule,
206
+ MatIconModule] });
207
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BxRestModule, decorators: [{
208
+ type: NgModule,
209
+ args: [{
210
+ declarations: [],
211
+ imports: [
212
+ MatIconModule,
213
+ MatButtonModule
214
+ ],
215
+ exports: [
216
+ MatButtonModule,
217
+ MatIconModule
218
+ ]
219
+ }]
220
+ }] });
221
+
222
+ class ToastMessageComponent {
223
+ constructor(data) {
224
+ this.data = data;
225
+ this.snackBarRef = inject(MatSnackBarRef);
226
+ }
227
+ getClass() {
228
+ switch (this.data.type) {
229
+ case 'error':
230
+ case 'warning':
231
+ case 'success':
232
+ return this.data.type + '-message';
233
+ }
234
+ return '';
235
+ }
236
+ }
237
+ ToastMessageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ToastMessageComponent, deps: [{ token: MAT_SNACK_BAR_DATA }], target: i0.ɵɵFactoryTarget.Component });
238
+ ToastMessageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.9", type: ToastMessageComponent, isStandalone: true, selector: "app-view", ngImport: i0, template: "<div class=\"w-100 d-flex\">\n <span matSnackBarLabel [class]=\"getClass()\">\n {{ data.message }}\n</span>\n <span matSnackBarActions [class]=\"getClass()\">\n <button mat-button matSnackBarAction (click)=\"snackBarRef.dismissWithAction()\">\n <mat-icon>\n close\n </mat-icon>\n </button>\n</span>\n</div>\n\n", styles: [":host{display:flex;background-color:red}:host .mdc-snackbar__surface{padding:0;margin:0}:host .error-message{color:red}:host.error-box{background-color:#eec1c1}:host.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.error-box .mdc-snackbar__surface{background-color:#eec1c1}mat-snack-bar-container.mdc-snackbar.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.warning-box .mdc-snackbar__surface{background-color:#f0f2b9}mat-snack-bar-container.mdc-snackbar.warning-box .warning-message{color:#15140f}mat-snack-bar-container.mdc-snackbar.success-box .mdc-snackbar__surface{background-color:#daf7d1}mat-snack-bar-container.mdc-snackbar.success-box .success-message{color:#423f31}\n"], dependencies: [{ kind: "ngmodule", type: BxRestModule }, { kind: "component", type: i1.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], encapsulation: i0.ViewEncapsulation.None });
239
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ToastMessageComponent, decorators: [{
240
+ type: Component,
241
+ args: [{ selector: 'app-view', encapsulation: ViewEncapsulation.None, standalone: true, imports: [BxRestModule], template: "<div class=\"w-100 d-flex\">\n <span matSnackBarLabel [class]=\"getClass()\">\n {{ data.message }}\n</span>\n <span matSnackBarActions [class]=\"getClass()\">\n <button mat-button matSnackBarAction (click)=\"snackBarRef.dismissWithAction()\">\n <mat-icon>\n close\n </mat-icon>\n </button>\n</span>\n</div>\n\n", styles: [":host{display:flex;background-color:red}:host .mdc-snackbar__surface{padding:0;margin:0}:host .error-message{color:red}:host.error-box{background-color:#eec1c1}:host.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.error-box .mdc-snackbar__surface{background-color:#eec1c1}mat-snack-bar-container.mdc-snackbar.error-box .error-message{color:red}mat-snack-bar-container.mdc-snackbar.warning-box .mdc-snackbar__surface{background-color:#f0f2b9}mat-snack-bar-container.mdc-snackbar.warning-box .warning-message{color:#15140f}mat-snack-bar-container.mdc-snackbar.success-box .mdc-snackbar__surface{background-color:#daf7d1}mat-snack-bar-container.mdc-snackbar.success-box .success-message{color:#423f31}\n"] }]
242
+ }], ctorParameters: function () {
243
+ return [{ type: undefined, decorators: [{
244
+ type: Inject,
245
+ args: [MAT_SNACK_BAR_DATA]
246
+ }] }];
247
+ } });
248
+
249
+ /**
250
+ * Сервис для вывода сообщений пользователю
251
+ * TODO: логирование
252
+ */
253
+ class SnackBarService {
254
+ constructor(snackBar) {
255
+ this.snackBar = snackBar;
256
+ }
257
+ error(message, sec = 12) {
258
+ this.standardMessage(message, sec, 'error');
259
+ }
260
+ warning(message, sec = 7) {
261
+ this.standardMessage(message, sec, 'warning');
262
+ }
263
+ success(message, sec = 7) {
264
+ this.standardMessage(message, sec, 'success');
265
+ }
266
+ standardMessage(message, sec = 5, name = 'error') {
267
+ this.snackBar.open(message);
268
+ this.snackBar.openFromComponent(ToastMessageComponent, {
269
+ duration: sec * 1000,
270
+ data: {
271
+ message: message,
272
+ type: name
273
+ },
274
+ panelClass: name + '-box'
275
+ });
276
+ }
277
+ }
278
+ SnackBarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, deps: [{ token: i1$1.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
279
+ SnackBarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, providedIn: 'root' });
280
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SnackBarService, decorators: [{
281
+ type: Injectable,
282
+ args: [{
283
+ providedIn: 'root'
284
+ }]
285
+ }], ctorParameters: function () { return [{ type: i1$1.MatSnackBar }]; } });
286
+
287
+ // Generate an internal UID to make the regexp pattern harder to guess.
288
+ const UID_LENGTH = 16;
289
+ const UID = generateUID();
290
+ const PLACE_HOLDER_REGEXP = new RegExp('(\\\\)?"@__(F|R|D|M|S|A|U|I|B|L)-' + UID + '-(\\d+)__@"', 'g');
291
+ const IS_NATIVE_CODE_REGEXP = /\{\s*\[native code]\s*}/g;
292
+ const IS_PURE_FUNCTION = /function.*?\(/;
293
+ const IS_ARROW_FUNCTION = /.*?=>.*?/;
294
+ const UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g;
295
+ const RESERVED_SYMBOLS = ['*', 'async'];
296
+ // Mapping of unsafe HTML and invalid JavaScript line terminator chars to their
297
+ // Unicode char counterparts which are safe to use in JavaScript strings.
298
+ const ESCAPED_CHARS = {
299
+ '<': '\\u003C',
300
+ '>': '\\u003E',
301
+ '/': '\\u002F',
302
+ '\u2028': '\\u2028',
303
+ '\u2029': '\\u2029'
304
+ };
305
+ function escapeUnsafeChars(unsafeChar) {
306
+ return (ESCAPED_CHARS.hasOwnProperty(unsafeChar)) ? ESCAPED_CHARS[unsafeChar] : '';
307
+ }
308
+ function generateUID() {
309
+ let bytes = window.crypto.getRandomValues(new Uint32Array(UID_LENGTH));
310
+ let result = '';
311
+ for (let i = 0; i < UID_LENGTH; ++i) {
312
+ result += bytes[i].toString(16);
313
+ }
314
+ return result;
315
+ }
316
+ function deleteFunctions(obj) {
317
+ let functionKeys = [];
318
+ for (let key in obj) {
319
+ if (typeof obj[key] === "function") {
320
+ functionKeys.push(key);
321
+ }
322
+ }
323
+ for (let i = 0; i < functionKeys.length; i++) {
324
+ delete obj[functionKeys[i]];
325
+ }
326
+ }
327
+ function serialize(obj, options = {}) {
328
+ // Backwards-compatibility for `space` as the second argument.
329
+ if (typeof options === 'number' || typeof options === 'string') {
330
+ options = { space: options };
331
+ }
332
+ let functions = [];
333
+ let regexps = [];
334
+ let dates = [];
335
+ let maps = [];
336
+ let sets = [];
337
+ let arrays = [];
338
+ let undefs = [];
339
+ let infinities = [];
340
+ let bigInts = [];
341
+ let urls = [];
342
+ // Returns placeholders for functions and regexps (identified by index)
343
+ // which are later replaced by their string representation.
344
+ function replacer(key, value) {
345
+ // For nested function
346
+ if (options.ignoreFunction) {
347
+ deleteFunctions(value);
348
+ }
349
+ if (!value && value !== undefined) {
350
+ return value;
351
+ }
352
+ // let origValue: any = this[key];
353
+ let origValue = value;
354
+ let type = typeof origValue;
355
+ switch (type) {
356
+ case 'object':
357
+ if (origValue instanceof RegExp) {
358
+ return '@__R-' + UID + '-' + (regexps.push(origValue) - 1) + '__@';
359
+ }
360
+ else if (origValue instanceof Date) {
361
+ return '@__D-' + UID + '-' + (dates.push(origValue) - 1) + '__@';
362
+ }
363
+ else if (origValue instanceof Map) {
364
+ return '@__M-' + UID + '-' + (maps.push(origValue) - 1) + '__@';
365
+ }
366
+ else if (origValue instanceof Set) {
367
+ return '@__S-' + UID + '-' + (sets.push(origValue) - 1) + '__@';
368
+ }
369
+ if (origValue instanceof Array) {
370
+ let isSparse = origValue.filter(function () {
371
+ return true;
372
+ }).length !== origValue.length;
373
+ if (isSparse) {
374
+ return '@__A-' + UID + '-' + (arrays.push(origValue) - 1) + '__@';
375
+ }
376
+ }
377
+ if (origValue instanceof URL) {
378
+ return '@__L-' + UID + '-' + (urls.push(origValue) - 1) + '__@';
379
+ }
380
+ break;
381
+ case 'function':
382
+ return '@__F-' + UID + '-' + (functions.push(origValue) - 1) + '__@';
383
+ case 'undefined':
384
+ return '@__U-' + UID + '-' + (undefs.push(origValue) - 1) + '__@';
385
+ case 'number':
386
+ return '@__I-' + UID + '-' + (infinities.push(origValue) - 1) + '__@';
387
+ case 'bigint':
388
+ return '@__B-' + UID + '-' + (bigInts.push(origValue) - 1) + '__@';
389
+ }
390
+ return value;
391
+ }
392
+ function serializeFunc(fn) {
393
+ let serializedFn = fn.toString();
394
+ if (IS_NATIVE_CODE_REGEXP.test(serializedFn)) {
395
+ throw new TypeError('Serializing native function: ' + fn.name);
396
+ }
397
+ // pure functions, example: {key: function() {}}
398
+ if (IS_PURE_FUNCTION.test(serializedFn)) {
399
+ return serializedFn;
400
+ }
401
+ // arrow functions, example: arg1 => arg1+5
402
+ if (IS_ARROW_FUNCTION.test(serializedFn)) {
403
+ return serializedFn;
404
+ }
405
+ let argsStartsAt = serializedFn.indexOf('(');
406
+ let def = serializedFn.slice(0, argsStartsAt)
407
+ .trim()
408
+ .split(' ')
409
+ .filter(function (val) {
410
+ return val.length > 0;
411
+ });
412
+ let nonReservedSymbols = def.filter(function (val) {
413
+ return RESERVED_SYMBOLS.indexOf(val) === -1;
414
+ });
415
+ // enhanced literal objects, example: {key() {}}
416
+ if (nonReservedSymbols.length > 0) {
417
+ return (def.indexOf('async') > -1 ? 'async ' : '') + 'function'
418
+ + (def.join('').indexOf('*') > -1 ? '*' : '')
419
+ + serializedFn.slice(argsStartsAt);
420
+ }
421
+ // arrow functions
422
+ return serializedFn;
423
+ }
424
+ // Check if the parameter is function
425
+ if (options.ignoreFunction && typeof obj === "function") {
426
+ obj = undefined;
427
+ }
428
+ // Protects against `JSON.stringify()` returning `undefined`, by serializing
429
+ // to the literal string: "undefined".
430
+ if (obj === undefined) {
431
+ return String(obj);
432
+ }
433
+ let str = '';
434
+ // Creates a JSON string representation of the value.
435
+ // NOTE: Node 0.12 goes into slow mode with extra JSON.stringify() args.
436
+ if (options.isJSON && !options.space) {
437
+ str = JSON.stringify(obj);
438
+ }
439
+ else {
440
+ str = JSON.stringify(obj, options.isJSON ? undefined : replacer, options.space);
441
+ }
442
+ // Replace unsafe HTML and invalid JavaScript line terminator chars with
443
+ // their safe Unicode char counterpart. This _must_ happen before the
444
+ // regexps and functions are serialized and added back to the string.
445
+ if (options.unsafe !== true) {
446
+ str = str.replace(UNSAFE_CHARS_REGEXP, escapeUnsafeChars);
447
+ }
448
+ if (functions.length === 0 && regexps.length === 0 && dates.length === 0 && maps.length === 0 && sets.length === 0 && arrays.length === 0 && undefs.length === 0 && infinities.length === 0 && bigInts.length === 0 && urls.length === 0) {
449
+ return str;
450
+ }
451
+ // Replaces all occurrences of function, regexp, date, map and set placeholders in the
452
+ // JSON string with their string representations. If the original value can
453
+ // not be found, then `undefined` is used.
454
+ return str.replace(PLACE_HOLDER_REGEXP, function (match, backSlash, type, valueIndex) {
455
+ // The placeholder may not be preceded by a backslash. This is to prevent
456
+ // replacing things like `"a\"@__R-<UID>-0__@"` and thus outputting
457
+ // invalid JS.
458
+ if (backSlash) {
459
+ return match;
460
+ }
461
+ switch (type) {
462
+ case 'D':
463
+ return "new Date(\"" + dates[valueIndex].toISOString() + "\")";
464
+ case 'R':
465
+ return "new RegExp(" + serialize(regexps[valueIndex].source) + ", \"" + regexps[valueIndex].flags + "\")";
466
+ case 'M':
467
+ return "new Map(" + serialize(Array.from(maps[valueIndex].entries()), options) + ")";
468
+ case 'S':
469
+ return "new Set(" + serialize(Array.from(sets[valueIndex].values()), options) + ")";
470
+ case 'A':
471
+ return "Array.prototype.slice.call(" + serialize(Object.assign({ length: arrays[valueIndex].length }, arrays[valueIndex]), options) + ")";
472
+ case 'U':
473
+ return 'undefined';
474
+ case 'I':
475
+ return infinities[valueIndex];
476
+ case 'B':
477
+ return "BigInt(\"" + bigInts[valueIndex] + "\")";
478
+ case 'L':
479
+ return "new URL(\"" + urls[valueIndex].toString() + "\")";
480
+ }
481
+ let fn = functions[valueIndex];
482
+ return serializeFunc(fn);
483
+ });
484
+ }
485
+
486
+ class JSONServices {
487
+ static deserialize(data) {
488
+ return eval('(' + data + ')');
489
+ }
490
+ static serialize(data) {
491
+ return serialize(data);
492
+ }
493
+ }
494
+ JSONServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
495
+ JSONServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, providedIn: 'root' });
496
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: JSONServices, decorators: [{
497
+ type: Injectable,
498
+ args: [{
499
+ providedIn: 'root'
500
+ }]
501
+ }] });
502
+
503
+ class CookiesServices {
504
+ static get(name) {
505
+ const results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
506
+ if (results)
507
+ return results[2];
508
+ else
509
+ return '';
510
+ }
511
+ static set(name, value, age = 0) {
512
+ let string = name + '=' + value + ';';
513
+ if (age) {
514
+ string += ' max-age=' + age;
515
+ }
516
+ string += '; SameSite=None; Secure';
517
+ document.cookie = string;
518
+ }
519
+ static setObj(name, value, age = 0) {
520
+ let string = name + '=' + JSONServices.serialize(value) + ';';
521
+ if (age) {
522
+ string += ' max-age=' + age;
523
+ }
524
+ string += '; SameSite=None; Secure';
525
+ document.cookie = string;
526
+ }
527
+ static getObj(name) {
528
+ const results = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
529
+ if (results) {
530
+ return JSONServices.deserialize(results[2]);
531
+ }
532
+ return false;
533
+ }
534
+ }
535
+ CookiesServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
536
+ CookiesServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, providedIn: 'root' });
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CookiesServices, decorators: [{
538
+ type: Injectable,
539
+ args: [{
540
+ providedIn: 'root'
541
+ }]
542
+ }] });
543
+
544
+ const save$1 = createAction('[Auth Component] Save', props());
545
+ const saveAccessToken = createAction('[Auth Component] SaveAccessToken', props());
546
+ const initialState$1 = {
547
+ access_token: '',
548
+ client_endpoint: '',
549
+ domain: '',
550
+ expires: 0,
551
+ expires_in: 0,
552
+ member_id: '',
553
+ refresh_token: '',
554
+ scope: '',
555
+ server_endpoint: '',
556
+ status: '',
557
+ user_id: 0
558
+ };
559
+ const _authReducer = createReducer(initialState$1, on(saveAccessToken, (s, data) => {
560
+ let copy = clone(s);
561
+ return Object.assign(copy, data);
562
+ }));
563
+ function authReducer(state = initialState$1, action) {
564
+ return _authReducer(state, action);
565
+ }
566
+
567
+ class LocalStorageServices {
568
+ static get(name) {
569
+ return localStorage.getItem(name);
570
+ }
571
+ static getObj(name) {
572
+ return JSONServices.deserialize(localStorage.getItem(name));
573
+ }
574
+ static set(name, value) {
575
+ localStorage.setItem(name, value);
576
+ }
577
+ static setObj(name, value) {
578
+ let get = this.get(name);
579
+ if (get && typeof get === 'object') {
580
+ localStorage.setItem(name, JSONServices.serialize(Object.assign(get, value)));
581
+ }
582
+ else {
583
+ localStorage.setItem(name, JSONServices.serialize(value));
584
+ }
585
+ }
586
+ static del(name) {
587
+ localStorage.removeItem(name);
588
+ }
589
+ }
590
+ LocalStorageServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
591
+ LocalStorageServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, providedIn: 'root' });
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: LocalStorageServices, decorators: [{
593
+ type: Injectable,
594
+ args: [{
595
+ providedIn: 'root'
596
+ }]
597
+ }] });
598
+
599
+ class RestServices {
600
+ constructor() {
601
+ this.BX24 = false;
602
+ // @ts-ignore
603
+ this.BX24 = (window.BX24) ? window.BX24 : false;
604
+ }
605
+ init(callBack) {
606
+ return (this.BX24) ? this.BX24.init(callBack) : false;
607
+ }
608
+ }
609
+ RestServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
610
+ RestServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, providedIn: 'root' });
611
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RestServices, decorators: [{
612
+ type: Injectable,
613
+ args: [{
614
+ providedIn: 'root'
615
+ }]
616
+ }], ctorParameters: function () { return []; } });
617
+
618
+ class SessionKeyServices extends BaseServices {
619
+ constructor(store, route, BxApiLib) {
620
+ super();
621
+ this.store = store;
622
+ this.route = route;
623
+ this.BxApiLib = BxApiLib;
624
+ this.authHave = false;
625
+ this.subscribe = {
626
+ authData: new Subscription()
627
+ };
628
+ this.authData$ = this.store.select('auth');
629
+ this.authData$.subscribe(authData => {
630
+ if ((authData && !authData.access_token.length) || !authData) {
631
+ // получаем токен по собственным каналом (в битриксе приложение trace:apps.trace)
632
+ window.addEventListener('message', (event) => {
633
+ if (event.origin !== window.origin) { // проверяем что это не наше сообщение (с текущего приложения)
634
+ if (event.data && event.data.param) {
635
+ if (typeof event.data.param === 'string') {
636
+ event.data.param = JSON.parse(event.data.param);
637
+ }
638
+ let save = {};
639
+ if (event.data.param.access_token) {
640
+ let param = event.data.param;
641
+ save.access_token = event.data.param.access_token;
642
+ save = {
643
+ access_token: (param.access_token) ? param.access_token : undefined,
644
+ client_endpoint: (param.client_endpoint) ? param.client_endpoint : undefined,
645
+ domain: (param.domain) ? param.domain : undefined,
646
+ expires: (param.expires) ? param.expires : undefined,
647
+ expires_in: (param.expires_in) ? param.expires_in : undefined,
648
+ member_id: (param.member_id) ? param.member_id : undefined,
649
+ refresh_token: (param.refresh_token) ? param.refresh_token : undefined,
650
+ scope: (param.scope) ? param.scope : undefined,
651
+ server_endpoint: (param.server_endpoint) ? param.server_endpoint : undefined,
652
+ status: (param.status) ? param.status : undefined,
653
+ user_id: (param.user_id) ? param.user_id : undefined,
654
+ type: (param.type) ? param.type : undefined,
655
+ };
656
+ }
657
+ if (Object.keys(save).length && save.access_token) {
658
+ this.store.dispatch(saveAccessToken(save));
659
+ this.subscribeAll();
660
+ }
661
+ }
662
+ }
663
+ });
664
+ this.subscribe.authData = this.route.queryParamMap
665
+ .pipe(filter(param => param.has('AUTH_ID')
666
+ || param.has('access_token')
667
+ || param.has('REFRESH_ID')
668
+ || param.has('DOMAIN')))
669
+ .subscribe((param) => {
670
+ let save = {};
671
+ if (param.has('AUTH_ID') && !authData.access_token.length) {
672
+ const get = param.get('AUTH_ID');
673
+ if (get) {
674
+ CookiesServices.set('auth', get); // потом убрать
675
+ save.access_token = get;
676
+ }
677
+ }
678
+ if (param.has('access_token') && !authData.access_token.length) {
679
+ const get = param.get('access_token');
680
+ if (get) {
681
+ CookiesServices.set('auth', get); // потом убрать
682
+ save.access_token = get;
683
+ }
684
+ }
685
+ if (param.has('REFRESH_ID') && !authData.refresh_token.length) {
686
+ const get = param.get('REFRESH_ID');
687
+ if (get) {
688
+ save.refresh_token = get;
689
+ }
690
+ }
691
+ if (param.has('DOMAIN') && !authData.domain.length) {
692
+ const get = param.get('DOMAIN');
693
+ if (get) {
694
+ save.domain = get;
695
+ }
696
+ }
697
+ if (Object.keys(save).length && save.access_token) {
698
+ this.store.dispatch(saveAccessToken(save));
699
+ this.subscribeAll();
700
+ }
701
+ else {
702
+ // если битрикс не шлёт нужные мне параметры на прямую
703
+ // просим их мне отдать так как описано это в документации
704
+ let f = () => {
705
+ if (this.BxApiLib.BX24) {
706
+ const initDate = this.BxApiLib.BX24.getAuth();
707
+ this.store.dispatch(saveAccessToken(initDate));
708
+ }
709
+ };
710
+ this.BxApiLib.init(f);
711
+ }
712
+ });
713
+ }
714
+ else if (this.getAuth().length) {
715
+ this.authHave = true;
716
+ }
717
+ this.authData = authData;
718
+ });
719
+ }
720
+ subscribeAll() {
721
+ this.subscribe.authData.unsubscribe();
722
+ }
723
+ getAuth() {
724
+ if (window.BX && window.BX.bitrix_sessid()) {
725
+ return window.BX.bitrix_sessid();
726
+ }
727
+ else if (this.getSessid().length) {
728
+ let str = this.getSessid();
729
+ return (str) ? str : '';
730
+ }
731
+ else {
732
+ return CookiesServices.get('auth');
733
+ }
734
+ }
735
+ getKeyAuth() {
736
+ if (window.BX && window.BX.bitrix_sessid()
737
+ || this.getSessid().length) {
738
+ return 'sessid';
739
+ }
740
+ else {
741
+ return 'auth';
742
+ }
743
+ }
744
+ getSessid() {
745
+ const check = new URLSearchParams(document.location.search).get('sessid');
746
+ if (check) {
747
+ LocalStorageServices.set('sessid', check);
748
+ return check;
749
+ }
750
+ else if (LocalStorageServices.get('sessid')) {
751
+ return LocalStorageServices.get('sessid');
752
+ }
753
+ return '';
754
+ }
755
+ setAuthParams(params) {
756
+ const keyAuth = this.getKeyAuth();
757
+ if (params[keyAuth]) {
758
+ return true;
759
+ }
760
+ else if (keyAuth) {
761
+ params[keyAuth] = this.getAuth();
762
+ return true;
763
+ }
764
+ return false;
765
+ }
766
+ getAuthParams() {
767
+ // if (env.production && !env.component) {
768
+ return this.authData$.pipe(take(1), map(v => (v) ? v.access_token : undefined));
769
+ // } else {
770
+ // return of(this.getAuth())
771
+ // }
772
+ }
773
+ getBaseUrl() {
774
+ return this.authData$.pipe(map(v => (v && v.domain) ? this.prepareBaseAddress(v.domain, 'b24.trace-studio.com') : undefined));
775
+ }
776
+ }
777
+ SessionKeyServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, deps: [{ token: i1$2.Store }, { token: i2$1.ActivatedRoute }, { token: RestServices }], target: i0.ɵɵFactoryTarget.Injectable });
778
+ SessionKeyServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, providedIn: 'root' });
779
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SessionKeyServices, decorators: [{
780
+ type: Injectable,
781
+ args: [{
782
+ providedIn: 'root'
783
+ }]
784
+ }], ctorParameters: function () { return [{ type: i1$2.Store }, { type: i2$1.ActivatedRoute }, { type: RestServices }]; } });
785
+
786
+ class HttpData extends BaseServices {
787
+ constructor() {
788
+ super(...arguments);
789
+ this.defSettings = {
790
+ timeZone: {
791
+ calc: true,
792
+ levelOut: false
793
+ }
794
+ };
795
+ }
796
+ getHttpParamsGet(// не так уж и сложно сделать сложенный HttpParams, да гугл?
797
+ obj, sendHttpParams = new HttpParams(), thisArray = false, nesting = [],
798
+ // settings = this.defSettings
799
+ _ = this.defSettings) {
800
+ for (const key in obj) {
801
+ let setKey = '';
802
+ if (nesting.length) {
803
+ let first = nesting[0];
804
+ setKey = (nesting.length > 1)
805
+ ? first + '[' + nesting.slice(1).join('][') + '][' + key + ']'
806
+ : first + '[' + key + ']';
807
+ }
808
+ else {
809
+ setKey = key;
810
+ }
811
+ switch (typeof obj[key]) {
812
+ case 'string':
813
+ sendHttpParams = sendHttpParams.set(setKey, obj[key]);
814
+ break;
815
+ case 'symbol':
816
+ case 'number':
817
+ case 'bigint':
818
+ case 'boolean':
819
+ sendHttpParams = sendHttpParams.set(setKey, String(obj[key]));
820
+ break;
821
+ case 'object':
822
+ nesting.push(key);
823
+ sendHttpParams = this.getHttpParamsGet(obj[key], sendHttpParams, false, nesting);
824
+ nesting.pop();
825
+ break;
826
+ case 'function':
827
+ case 'undefined':
828
+ default:
829
+ console.error('Ты отправил что-то не то', obj[key], typeof obj[key], typeof obj);
830
+ }
831
+ }
832
+ return sendHttpParams;
833
+ }
834
+ getHttpParamsPost(obj, sendHttpParams = new FormData(), thisArray = false, nesting = [], settings = this.defSettings) {
835
+ if (obj instanceof Blob) {
836
+ let first = nesting[0];
837
+ let setKey = (nesting.length > 1)
838
+ ? first + '[' + nesting.slice(1).join('][') + ']'
839
+ : first;
840
+ sendHttpParams.set(setKey, obj);
841
+ return sendHttpParams;
842
+ }
843
+ else if (obj instanceof Date) {
844
+ let first = nesting[0];
845
+ let tzoffset = (settings.timeZone.calc) ? obj.getTimezoneOffset() * 60000 : 0; // вычисляем влияние часового пояса
846
+ let levelOut = (settings.timeZone.levelOut) ? obj.getTimezoneOffset() * 60000 : 0; // вычисляем влияние часового пояса
847
+ let setKey = (nesting.length > 1)
848
+ ? first + '[' + nesting.slice(1).join('][') + ']'
849
+ : first;
850
+ sendHttpParams.set(setKey, (new Date(obj.valueOf() + tzoffset - levelOut)).toISOString());
851
+ return sendHttpParams;
852
+ }
853
+ else {
854
+ for (const key in obj) {
855
+ let setKey = '';
856
+ if (nesting.length) {
857
+ let first = nesting[0];
858
+ setKey = (nesting.length > 1)
859
+ ? first + '[' + nesting.slice(1).join('][') + '][' + key + ']'
860
+ : first + '[' + key + ']';
861
+ }
862
+ else {
863
+ setKey = key;
864
+ }
865
+ switch (typeof obj[key]) {
866
+ case 'string':
867
+ sendHttpParams.set(setKey, obj[key]);
868
+ break;
869
+ case 'symbol':
870
+ case 'number':
871
+ case 'bigint':
872
+ case 'boolean':
873
+ sendHttpParams.set(setKey, String(obj[key]));
874
+ break;
875
+ case 'object':
876
+ nesting.push(key);
877
+ sendHttpParams = this.getHttpParamsPost(obj[key], sendHttpParams, false, nesting, settings);
878
+ nesting.pop();
879
+ break;
880
+ case 'function':
881
+ case 'undefined':
882
+ default:
883
+ console.error('Ты отправил что-то не то', obj[key], typeof obj[key], typeof obj);
884
+ }
885
+ }
886
+ }
887
+ return sendHttpParams;
888
+ }
889
+ mapResult(v) {
890
+ if (v && (v.result || typeof v.result === 'boolean')) {
891
+ return v.result;
892
+ }
893
+ return undefined;
894
+ }
895
+ sliceArrayIntoChunks(arr, chunkSize) {
896
+ const res = [];
897
+ for (let i = 0; i < arr.length; i += chunkSize) {
898
+ const chunk = arr.slice(i, i + chunkSize);
899
+ res.push(chunk);
900
+ }
901
+ return res;
902
+ }
903
+ removingMultipleSlashes(str) {
904
+ return str.replace(/\/{2,}/g, '/');
905
+ }
906
+ }
907
+
908
+ class BaseHttp extends HttpData {
909
+ constructor(http, snackBar) {
910
+ super();
911
+ this.http = http;
912
+ this.snackBar = snackBar;
913
+ }
914
+ handleError(result, textError = 'получения данных') {
915
+ return (error) => {
916
+ console.error(`failed: ${error.message}`);
917
+ this.snackBar.error('Ошибка: ' + textError);
918
+ return of(result);
919
+ };
920
+ }
921
+ }
922
+ BaseHttp.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, deps: [{ token: i1$3.HttpClient }, { token: SnackBarService }], target: i0.ɵɵFactoryTarget.Injectable });
923
+ BaseHttp.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, providedIn: 'root' });
924
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseHttp, decorators: [{
925
+ type: Injectable,
926
+ args: [{
927
+ providedIn: 'root'
928
+ }]
929
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: SnackBarService }]; } });
930
+
931
+ class BaseHttpServices extends BaseHttp {
932
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
933
+ return this.http.get(url, {
934
+ params: this.getHttpParamsGet(params, new HttpParams(), false, [], settings)
935
+ }).pipe(catchError(err => {
936
+ if (!textError.length && err.error.error_description) {
937
+ textError = err.error.error_description;
938
+ }
939
+ this.snackBar.error('Ошибка: ' + textError);
940
+ return throwError(() => err);
941
+ }));
942
+ }
943
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
944
+ return this.http.post(url, this.getHttpParamsPost(params, new FormData(), false, [], settings)).pipe(catchError(err => {
945
+ if (!textError.length && err.error.error_description) {
946
+ textError = err.error.error_description;
947
+ }
948
+ this.snackBar.error('Ошибка: ' + textError);
949
+ console.error(err);
950
+ return throwError(() => err);
951
+ }));
952
+ }
953
+ }
954
+
955
+ class HttpServices extends BaseHttpServices {
956
+ constructor(http, snackBar, session) {
957
+ super(http, snackBar);
958
+ this.session = session;
959
+ }
960
+ timeNowOnServer() {
961
+ return this.httpGet('server.time').pipe(map(v => {
962
+ if (v && v.result) {
963
+ return new Date(v.result);
964
+ }
965
+ return undefined;
966
+ }));
967
+ }
968
+ /**
969
+ * Это пиздец а не метод
970
+ * @param param
971
+ */
972
+ branch(param) {
973
+ let prepareParam = Object.entries(this.prepareBatch(param));
974
+ const size = 50; // больше не отдаст
975
+ let subarray = []; //массив в который будет выведен результат.
976
+ for (let i = 0; i < Math.ceil(prepareParam.length / size); i++) {
977
+ subarray[i] = prepareParam.slice((i * size), (i * size) + size);
978
+ }
979
+ return forkJoin(subarray.map(i => {
980
+ return this.httpPost('batch.json', {
981
+ halt: 0,
982
+ cmd: Object.assign({}, ...i.map(x => {
983
+ return { [x[0]]: x[1] };
984
+ }))
985
+ });
986
+ }));
987
+ }
988
+ prepareBatch(param) {
989
+ let res = Object.keys(param).reduce((obj, key) => {
990
+ obj[key] = '';
991
+ return obj;
992
+ }, {});
993
+ for (let key in param) {
994
+ if (typeof key === 'string' || typeof key === 'number' && param[key].param) {
995
+ res[key] = param[key].name + '?' + this.getHttpParamsGet(param[key].param).toString();
996
+ }
997
+ }
998
+ return res;
999
+ }
1000
+ mapBranchResult(res) {
1001
+ return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined));
1002
+ }
1003
+ mapBranchResultWithoutKey(res) {
1004
+ return flatten(Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)));
1005
+ }
1006
+ post(name, params = {}, textError = '', settings = this.defSettings) {
1007
+ return this.httpPost(this.getNameMethod(name), params, textError, settings);
1008
+ }
1009
+ get(name, params = {}, textError = '', settings = this.defSettings) {
1010
+ return this.httpGet(this.getNameMethod(name), params, textError, settings);
1011
+ }
1012
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
1013
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1014
+ if (auth) {
1015
+ const paramsClone = clone(params);
1016
+ paramsClone[this.session.getKeyAuth()] = auth;
1017
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1018
+ if (v) {
1019
+ return this.http.post(this.prepareBaseAddress(v) + url, this.getHttpParamsPost(paramsClone, new FormData(), false, [], settings))
1020
+ .pipe(take(1), catchError(err => {
1021
+ if (!textError.length && err.error.error_description) {
1022
+ textError = err.error.error_description;
1023
+ }
1024
+ this.snackBar.error('Ошибка: ' + textError);
1025
+ return throwError(() => err);
1026
+ }));
1027
+ }
1028
+ return throwError(() => 'get base url error');
1029
+ }));
1030
+ }
1031
+ else {
1032
+ this.snackBar.error('Error: Auth not get');
1033
+ return throwError(() => 'auth not get');
1034
+ }
1035
+ }));
1036
+ }
1037
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
1038
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1039
+ if (auth) {
1040
+ if (params === null) {
1041
+ params = {};
1042
+ }
1043
+ const paramsClone = clone(params);
1044
+ paramsClone[this.session.getKeyAuth()] = auth;
1045
+ let options = {
1046
+ params: this.getHttpParamsGet(paramsClone)
1047
+ };
1048
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1049
+ if (v) {
1050
+ return this.http.get(this.prepareBaseAddress(v) + url, options).pipe(take(1), catchError(err => {
1051
+ if (!textError.length && err.error.error_description) {
1052
+ textError = err.error.error_description;
1053
+ }
1054
+ this.snackBar.error('Ошибка: ' + textError);
1055
+ return throwError(() => err);
1056
+ }));
1057
+ }
1058
+ return throwError(() => 'get base url error');
1059
+ }));
1060
+ }
1061
+ else {
1062
+ this.snackBar.error('Error: Auth not get');
1063
+ return throwError(() => 'auth not get');
1064
+ }
1065
+ }));
1066
+ }
1067
+ getNameMethod(arr) {
1068
+ return arr.join('.');
1069
+ }
1070
+ }
1071
+ HttpServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, deps: [{ token: i1$3.HttpClient }, { token: SnackBarService }, { token: SessionKeyServices }], target: i0.ɵɵFactoryTarget.Injectable });
1072
+ HttpServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, providedIn: 'root' });
1073
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpServices, decorators: [{
1074
+ type: Injectable,
1075
+ args: [{
1076
+ providedIn: 'root'
1077
+ }]
1078
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: SnackBarService }, { type: SessionKeyServices }]; } });
1079
+
1080
+ class HttpBXServices extends HttpServices {
1081
+ timeNowOnServer() {
1082
+ return this.httpGet('server.time').pipe(map(v => {
1083
+ if (v && v.result) {
1084
+ return new Date(v.result);
1085
+ }
1086
+ return undefined;
1087
+ }));
1088
+ }
1089
+ /**
1090
+ * Это пиздец а не метод
1091
+ * @param param
1092
+ */
1093
+ branch(param) {
1094
+ let prepareParam = Object.entries(this.prepareBatch(param));
1095
+ const size = 50; // больше не отдаст
1096
+ let subarray = []; //массив в который будет выведен результат.
1097
+ for (let i = 0; i < Math.ceil(prepareParam.length / size); i++) {
1098
+ subarray[i] = prepareParam.slice((i * size), (i * size) + size);
1099
+ }
1100
+ return forkJoin(subarray.map(i => {
1101
+ return this.httpPost('batch.json', {
1102
+ halt: 0,
1103
+ cmd: Object.assign({}, ...i.map(x => {
1104
+ return { [x[0]]: x[1] };
1105
+ }))
1106
+ });
1107
+ }));
1108
+ }
1109
+ prepareBatch(param) {
1110
+ let res = Object.keys(param).reduce((obj, key) => {
1111
+ obj[key] = '';
1112
+ return obj;
1113
+ }, {});
1114
+ for (let key in param) {
1115
+ if (typeof key === 'string' || typeof key === 'number' && param[key].param) {
1116
+ res[key] = param[key].name + '?' + this.getHttpParamsGet(param[key].param).toString();
1117
+ }
1118
+ }
1119
+ return res;
1120
+ }
1121
+ mapBranchResult(res) {
1122
+ return Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined));
1123
+ }
1124
+ mapBranchResultWithoutKey(res) {
1125
+ return flatten(Object.assign([], ...res.map(i => (i.result && i.result.result) ? i.result.result : undefined)));
1126
+ }
1127
+ post(name, params = {}, textError = '', settings = this.defSettings) {
1128
+ return this.httpPost(this.getNameMethod(name), params, textError, settings);
1129
+ }
1130
+ get(name, params = {}, textError = '', settings = this.defSettings) {
1131
+ return this.httpGet(this.getNameMethod(name), params, textError, settings);
1132
+ }
1133
+ httpPost(url, params = {}, textError = '', settings = this.defSettings) {
1134
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1135
+ if (auth) {
1136
+ const paramsClone = clone(params);
1137
+ paramsClone[this.session.getKeyAuth()] = auth;
1138
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1139
+ if (v) {
1140
+ return this.http.post(this.prepareBaseAddress(v) + url, this.getHttpParamsPost(paramsClone, new FormData(), false, [], settings))
1141
+ .pipe(take(1), catchError(err => {
1142
+ if (!textError.length && err.error.error_description) {
1143
+ textError = err.error.error_description;
1144
+ }
1145
+ this.snackBar.error('Ошибка: ' + textError);
1146
+ return throwError(() => err);
1147
+ }));
1148
+ }
1149
+ return throwError(() => 'get base url error');
1150
+ }));
1151
+ }
1152
+ else {
1153
+ this.snackBar.error('Error: Auth not get');
1154
+ return throwError(() => 'auth not get');
1155
+ }
1156
+ }));
1157
+ }
1158
+ httpGet(url, params = {}, textError = '', settings = this.defSettings) {
1159
+ return this.session.getAuthParams().pipe(mergeMap(auth => {
1160
+ if (auth) {
1161
+ if (params === null) {
1162
+ params = {};
1163
+ }
1164
+ const paramsClone = clone(params);
1165
+ paramsClone[this.session.getKeyAuth()] = auth;
1166
+ let options = {
1167
+ params: this.getHttpParamsGet(paramsClone)
1168
+ };
1169
+ return this.session.getBaseUrl().pipe(mergeMap(v => {
1170
+ if (v) {
1171
+ return this.http.get(this.prepareBaseAddress(v) + url, options).pipe(take(1), catchError(err => {
1172
+ if (!textError.length && err.error.error_description) {
1173
+ textError = err.error.error_description;
1174
+ }
1175
+ this.snackBar.error('Ошибка: ' + textError);
1176
+ return throwError(() => err);
1177
+ }));
1178
+ }
1179
+ return throwError(() => 'get base url error');
1180
+ }));
1181
+ }
1182
+ else {
1183
+ this.snackBar.error('Error: Auth not get');
1184
+ return throwError(() => 'auth not get');
1185
+ }
1186
+ }));
1187
+ }
1188
+ getNameMethod(arr) {
1189
+ return arr.join('.');
1190
+ }
1191
+ }
1192
+ HttpBXServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1193
+ HttpBXServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, providedIn: 'root' });
1194
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: HttpBXServices, decorators: [{
1195
+ type: Injectable,
1196
+ args: [{
1197
+ providedIn: 'root'
1198
+ }]
1199
+ }] });
1200
+
186
1201
  const save = createAction('[Users Component] Save', props());
187
1202
  const saveArr = createAction('[Users Component] Save Arr', props());
188
1203
  const update = createAction('[Users Component] Update', props());
@@ -259,6 +1274,102 @@ const $meeting = 'meeting';
259
1274
  const $list = 'list';
260
1275
  const $search = 'search';
261
1276
 
1277
+ class BaseMapServices extends BaseServices {
1278
+ }
1279
+ BaseMapServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1280
+ BaseMapServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, providedIn: 'root' });
1281
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BaseMapServices, decorators: [{
1282
+ type: Injectable,
1283
+ args: [{
1284
+ providedIn: 'root'
1285
+ }]
1286
+ }] });
1287
+
1288
+ class BitrixApiUserMapServices extends BaseMapServices {
1289
+ HttpToBX(user) {
1290
+ let res = Object.assign(clone(user), {
1291
+ ID: this.toNumber(user.ID),
1292
+ IS_ONLINE: this.toBool(user.IS_ONLINE),
1293
+ DATE_REGISTER: this.toDate(user.DATE_REGISTER),
1294
+ PERSONAL_BIRTHDAY: this.toDate(user.PERSONAL_BIRTHDAY),
1295
+ });
1296
+ if (user.LAST_LOGIN) {
1297
+ res.LAST_LOGIN = this.toDate(user.LAST_LOGIN);
1298
+ }
1299
+ return res;
1300
+ }
1301
+ BXtoHttp(user) {
1302
+ return Object.assign(clone(user), {
1303
+ ID: this.toStr(user.ID),
1304
+ IS_ONLINE: this.toBXYorN(user.IS_ONLINE),
1305
+ DATE_REGISTER: this.getBXStrTime(user.DATE_REGISTER),
1306
+ PERSONAL_BIRTHDAY: this.toStr(user.PERSONAL_BIRTHDAY),
1307
+ LAST_LOGIN: this.toStr(user.LAST_LOGIN)
1308
+ });
1309
+ }
1310
+ getFIO(user) {
1311
+ let res = '';
1312
+ if (!user.LAST_NAME) {
1313
+ const SECOND_NAME = (user.SECOND_NAME) ? user.SECOND_NAME : '';
1314
+ const NAME = (user.NAME) ? user.NAME : '';
1315
+ res = NAME + ' ' + SECOND_NAME;
1316
+ }
1317
+ else if (!user.NAME) {
1318
+ res = user.LAST_NAME;
1319
+ }
1320
+ else if (!user.SECOND_NAME) {
1321
+ res = user.LAST_NAME + ' ' + user.NAME;
1322
+ }
1323
+ else {
1324
+ res = user.LAST_NAME + ' ' + user.NAME + ' ' + user.SECOND_NAME;
1325
+ }
1326
+ return res.trim();
1327
+ }
1328
+ getFI(user) {
1329
+ let res = '';
1330
+ if (!user.LAST_NAME) {
1331
+ const NAME = (user.NAME) ? user.NAME : '';
1332
+ res = NAME;
1333
+ }
1334
+ else if (!user.NAME) {
1335
+ res = user.LAST_NAME;
1336
+ }
1337
+ else {
1338
+ res = user.LAST_NAME + ' ' + user.NAME;
1339
+ }
1340
+ return res.trim();
1341
+ }
1342
+ getFIOShort(user) {
1343
+ let res = '';
1344
+ if (!user.LAST_NAME) {
1345
+ const SECOND_NAME = (user.SECOND_NAME) ? user.SECOND_NAME : '';
1346
+ const NAME = (user.NAME) ? user.NAME : '';
1347
+ res = NAME + ' ' + SECOND_NAME;
1348
+ }
1349
+ else if (!user.NAME) {
1350
+ res = user.LAST_NAME;
1351
+ }
1352
+ else if (!user.SECOND_NAME) {
1353
+ res = user.LAST_NAME + ' ' + user.NAME.charAt(0).toUpperCase() + '.';
1354
+ }
1355
+ else {
1356
+ res =
1357
+ user.LAST_NAME + ' ' +
1358
+ user.NAME.charAt(0).toUpperCase() + '.' +
1359
+ user.SECOND_NAME.charAt(0).toUpperCase() + '.';
1360
+ }
1361
+ return res.trim();
1362
+ }
1363
+ }
1364
+ BitrixApiUserMapServices.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
1365
+ BitrixApiUserMapServices.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, providedIn: 'root' });
1366
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BitrixApiUserMapServices, decorators: [{
1367
+ type: Injectable,
1368
+ args: [{
1369
+ providedIn: 'root'
1370
+ }]
1371
+ }] });
1372
+
262
1373
  class BXRestUser {
263
1374
  constructor(http, snackBar,
264
1375
  // private img: ImgServices,
@@ -310,7 +1421,7 @@ class BXRestUser {
310
1421
  }
311
1422
  getByIDs(ids, reload = true) {
312
1423
  ids = Array.from(new Set(ids));
313
- return this.user$.pipe(take(1), mergeMap(v => {
1424
+ return this.user$.pipe(take(1), mergeMap$1(v => {
314
1425
  if (!reload) {
315
1426
  let find = v.data.filter(i => ids.includes(i.ID));
316
1427
  if (find && find.length === ids.length) {
@@ -325,7 +1436,7 @@ class BXRestUser {
325
1436
  return this.getSelfHttp();
326
1437
  }
327
1438
  else {
328
- return this.user$.pipe(mergeMap(v => {
1439
+ return this.user$.pipe(mergeMap$1(v => {
329
1440
  if (v && v.self) {
330
1441
  return of(v.self);
331
1442
  }
@@ -353,7 +1464,7 @@ class BXRestUser {
353
1464
  }
354
1465
  getByDepartment(id) {
355
1466
  const ids = (typeof id === 'number') ? [id] : id;
356
- return this.user$.pipe(first(), mergeMap(v => {
1467
+ return this.user$.pipe(first(), mergeMap$1(v => {
357
1468
  if (v.load.all) {
358
1469
  return of(clone(v.data.filter(i => ids.find(id => i.UF_DEPARTMENT.includes(id)))));
359
1470
  }
@@ -370,7 +1481,7 @@ class BXRestUser {
370
1481
  params = clone(this.def.params);
371
1482
  }
372
1483
  const saveAllUser = compare(params, this.def.params);
373
- return this.user$.pipe(take(1), mergeMap(v => {
1484
+ return this.user$.pipe(take(1), mergeMap$1(v => {
374
1485
  if (v.load.all) {
375
1486
  if (compare(this.def.params, params)) {
376
1487
  return of(clone(v.data));
@@ -391,7 +1502,7 @@ class BXRestUser {
391
1502
  }));
392
1503
  }
393
1504
  getAllByPersonalBirthday(day = undefined, month = undefined, checkWeekend = false) {
394
- return this.http.timeNowOnServer().pipe(mergeMap(date => {
1505
+ return this.http.timeNowOnServer().pipe(mergeMap$1(date => {
395
1506
  if (date) {
396
1507
  let daySent = (day) ? day : date.getDate();
397
1508
  let start = date.getFullYear() + 1;
@@ -473,7 +1584,7 @@ class BXRestUser {
473
1584
  }
474
1585
  }
475
1586
  getEndArray(params = {}) {
476
- return this.get(params).pipe(mergeMap(items => {
1587
+ return this.get(params).pipe(mergeMap$1(items => {
477
1588
  if (items && items.result && typeof items.result === 'object') {
478
1589
  if (items.next) {
479
1590
  params.start = items.next;
@@ -514,7 +1625,15 @@ class BXRestUser {
514
1625
  itIsAdmin() {
515
1626
  return this.http.get(this.url.admin).pipe(map(v => this.http.mapResult(v)));
516
1627
  }
517
- }
1628
+ }
1629
+ BXRestUser.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, deps: [{ token: HttpBXServices }, { token: SnackBarService }, { token: i1$2.Store }, { token: BitrixApiUserMapServices }, { token: i3.DatePipe }], target: i0.ɵɵFactoryTarget.Injectable });
1630
+ BXRestUser.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, providedIn: 'root' });
1631
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: BXRestUser, decorators: [{
1632
+ type: Injectable,
1633
+ args: [{
1634
+ providedIn: 'root'
1635
+ }]
1636
+ }], ctorParameters: function () { return [{ type: HttpBXServices }, { type: SnackBarService }, { type: i1$2.Store }, { type: BitrixApiUserMapServices }, { type: i3.DatePipe }]; } });
518
1637
 
519
1638
  /*
520
1639
  * Public API Surface of bx-rest