bx-rest 0.0.10 → 0.0.12

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