@experteam-mx/ngx-services 18.3.6 → 18.4.0

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.
Files changed (46) hide show
  1. package/esm2022/lib/apis/api-companies.service.mjs +3 -3
  2. package/esm2022/lib/apis/api-invoices.service.mjs +4 -14
  3. package/esm2022/lib/apis/api-reports.service.mjs +4 -40
  4. package/esm2022/lib/apis/api-security.service.mjs +4 -30
  5. package/esm2022/lib/apis/api-shipments.service.mjs +4 -14
  6. package/esm2022/lib/apis/models/api-invoices.types.mjs +1 -1
  7. package/esm2022/lib/apis/models/api-reports.interfaces.mjs +1 -1
  8. package/esm2022/lib/apis/models/api-reports.types.mjs +1 -1
  9. package/esm2022/lib/apis/models/api-security.interfaces.mjs +1 -1
  10. package/esm2022/lib/apis/models/api-shipments.types.mjs +1 -1
  11. package/esm2022/lib/cypher/crypto.service.mjs +3 -3
  12. package/esm2022/lib/interceptors/api-headers.interceptor.mjs +22 -36
  13. package/esm2022/lib/interceptors/api-token.interceptor.mjs +25 -39
  14. package/esm2022/lib/interceptors/http-caching.interceptor.mjs +30 -43
  15. package/esm2022/lib/ngx-services.models.mjs +11 -2
  16. package/esm2022/lib/ngx-services.module.mjs +4 -4
  17. package/esm2022/public-api.mjs +2 -10
  18. package/fesm2022/experteam-mx-ngx-services.mjs +107 -455
  19. package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
  20. package/lib/apis/api-invoices.service.d.ts +2 -9
  21. package/lib/apis/api-reports.service.d.ts +1 -17
  22. package/lib/apis/api-security.service.d.ts +0 -19
  23. package/lib/apis/api-shipments.service.d.ts +2 -9
  24. package/lib/apis/models/api-invoices.types.d.ts +0 -29
  25. package/lib/apis/models/api-reports.interfaces.d.ts +0 -149
  26. package/lib/apis/models/api-reports.types.d.ts +1 -11
  27. package/lib/apis/models/api-security.interfaces.d.ts +0 -4
  28. package/lib/apis/models/api-shipments.types.d.ts +0 -41
  29. package/lib/interceptors/api-headers.interceptor.d.ts +11 -16
  30. package/lib/interceptors/api-token.interceptor.d.ts +10 -20
  31. package/lib/interceptors/http-caching.interceptor.d.ts +11 -19
  32. package/lib/ngx-services.models.d.ts +26 -9
  33. package/package.json +2 -3
  34. package/public-api.d.ts +1 -7
  35. package/esm2022/lib/apis/api-external-pickups.service.mjs +0 -72
  36. package/esm2022/lib/apis/api-open-items.service.mjs +0 -62
  37. package/esm2022/lib/apis/models/api-external-pickups.types.mjs +0 -2
  38. package/esm2022/lib/apis/models/api-open-items.interfaces.mjs +0 -2
  39. package/esm2022/lib/apis/models/api-open-items.types.mjs +0 -2
  40. package/esm2022/lib/websockets/web-sockets.service.mjs +0 -115
  41. package/lib/apis/api-external-pickups.service.d.ts +0 -45
  42. package/lib/apis/api-open-items.service.d.ts +0 -41
  43. package/lib/apis/models/api-external-pickups.types.d.ts +0 -31
  44. package/lib/apis/models/api-open-items.interfaces.d.ts +0 -32
  45. package/lib/apis/models/api-open-items.types.d.ts +0 -58
  46. package/lib/websockets/web-sockets.service.d.ts +0 -49
@@ -1,12 +1,21 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgModule, Injectable, Inject } from '@angular/core';
2
+ import { InjectionToken, NgModule, Injectable, Inject, inject } from '@angular/core';
3
3
  import * as i1 from '@angular/common/http';
4
4
  import { provideHttpClient, HttpParams, HttpHeaders, HttpResponse } from '@angular/common/http';
5
- import { map, mergeMap, forkJoin, tap, Observable, of } from 'rxjs';
6
- import { map as map$1, tap as tap$1 } from 'rxjs/operators';
5
+ import { map, mergeMap, forkJoin, tap, of } from 'rxjs';
7
6
  import * as i1$1 from 'ngx-cookie-service';
8
- import Pusher__default from 'pusher-js';
9
- export * from 'pusher-js';
7
+ import { CookieService } from 'ngx-cookie-service';
8
+ import { tap as tap$1 } from 'rxjs/operators';
9
+
10
+ /**
11
+ * Injection token used to inject environment configurations.
12
+ *
13
+ * `ENVIRONMENT_TOKEN` is a dependency injection token that allows
14
+ * for the provision and retrieval of environment-specific configurations
15
+ * within the application. This token is typically associated with an
16
+ * `Environment` type that defines the structure of the configuration.
17
+ */
18
+ const ENVIRONMENT_TOKEN = new InjectionToken('Environments token');
10
19
 
11
20
  class NgxServicesModule {
12
21
  /**
@@ -27,11 +36,11 @@ class NgxServicesModule {
27
36
  ]
28
37
  };
29
38
  }
30
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
31
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule });
32
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
39
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
40
+ static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule });
41
+ static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, providers: [provideHttpClient()] });
33
42
  }
34
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: NgxServicesModule, decorators: [{
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NgxServicesModule, decorators: [{
35
44
  type: NgModule,
36
45
  args: [{
37
46
  providers: [provideHttpClient()]
@@ -353,10 +362,10 @@ class ApiCompaniesService {
353
362
  params: httpParams(params),
354
363
  }).pipe(map(({ data }) => data));
355
364
  }
356
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
357
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
365
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
366
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, providedIn: 'root' });
358
367
  }
359
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiCompaniesService, decorators: [{
368
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiCompaniesService, decorators: [{
360
369
  type: Injectable,
361
370
  args: [{
362
371
  providedIn: 'root'
@@ -366,74 +375,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
366
375
  args: ['env']
367
376
  }] }, { type: i1.HttpClient }] });
368
377
 
369
- class ApiExternalPickupsService {
370
- httpClient;
371
- environment;
372
- constructor(httpClient, environment) {
373
- this.httpClient = httpClient;
374
- this.environment = environment;
375
- }
376
- /**
377
- * Getter method to retrieve the API's external operations URL.
378
- * Fetches the URL from the `apiExternalOperationsUrl` property of the environment object.
379
- * Defaults to an empty string if the property is undefined or null.
380
- *
381
- * @return {string} The external operations URL or an empty string if unavailable.
382
- */
383
- get url() {
384
- return this.environment.apiExternalOperationsUrl ?? '';
385
- }
386
- /**
387
- * Generates a delivery confirmation by sending the provided payload to the API.
388
- *
389
- * @param {GenerateDeliveryConfirmationIn} payload - The input payload required to generate the delivery confirmation.
390
- * @return {Observable<KeyOTPOut>} An observable that emits the generated delivery confirmation data.
391
- */
392
- generateDeliveryConfirmation(payload) {
393
- return this.httpClient.post(`${this.url}/delivery-confirmation/generate`, payload, {
394
- headers: { appkey: this.environment.apiExternalOperationsKey }
395
- }).pipe(map$1(({ data }) => data));
396
- }
397
- /**
398
- * Confirms the completion of a delivery operation by making a PATCH request.
399
- *
400
- * @param {Object} input - The input parameters for the method.
401
- * @param {string} input.operationId - The unique identifier of the delivery operation to be confirmed.
402
- * @param {string} input.keyOTP - The one-time password (OTP) key associated with the delivery confirmation.
403
- * @return {Observable<Object>} - An observable containing the response data from the API.
404
- */
405
- completedDeliveryConfirmation({ keyOTP, operationId, }) {
406
- return this.httpClient.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
407
- headers: { appkey: this.environment.apiExternalOperationsKey },
408
- params: { operation_id: operationId }
409
- }).pipe(map$1(({ data }) => data));
410
- }
411
- /**
412
- * Cancels a delivery confirmation by sending an OTP and additional data to the server.
413
- *
414
- * @param {Object} param0 - The parameter object containing the required properties.
415
- * @param {string} param0.otp - The one-time password to authenticate the cancellation request.
416
- * @param {Object} param0.body - Additional body data required for cancellation.
417
- * @return {Observable<Object>} An observable that emits the server's response when the cancellation is processed.
418
- */
419
- cancelDeliveryConfirmation({ otp, ...body }) {
420
- return this.httpClient.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
421
- headers: { appkey: this.environment.apiExternalOperationsKey },
422
- }).pipe(map$1(({ data }) => data));
423
- }
424
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
425
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, providedIn: 'root' });
426
- }
427
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiExternalPickupsService, decorators: [{
428
- type: Injectable,
429
- args: [{
430
- providedIn: 'root'
431
- }]
432
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
433
- type: Inject,
434
- args: ['env']
435
- }] }] });
436
-
437
378
  class ApiInvoicesService {
438
379
  environments;
439
380
  http;
@@ -449,16 +390,6 @@ class ApiInvoicesService {
449
390
  get url() {
450
391
  return this.environments.apiInvoicesUrl;
451
392
  }
452
- /**
453
- * Sends an operation document to the server and processes the response.
454
- *
455
- * @param {OperationDocumentIn} body - The input data for the operation document.
456
- * @return {Observable<OperationDocumentOut>} An observable containing the processed operation document output.
457
- */
458
- operationDocument(body) {
459
- return this.http.post(`${this.url}/operation/document`, body)
460
- .pipe(map(({ data }) => data));
461
- }
462
393
  /**
463
394
  * Fetches and returns the collection receipt data for a given collection ID.
464
395
  *
@@ -501,68 +432,10 @@ class ApiInvoicesService {
501
432
  return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
502
433
  .pipe(map(({ data }) => data));
503
434
  }
504
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
505
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
506
- }
507
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, decorators: [{
508
- type: Injectable,
509
- args: [{
510
- providedIn: 'root'
511
- }]
512
- }], ctorParameters: () => [{ type: undefined, decorators: [{
513
- type: Inject,
514
- args: ['env']
515
- }] }, { type: i1.HttpClient }] });
516
-
517
- class ApiOpenItemsService {
518
- environments;
519
- http;
520
- constructor(environments, http) {
521
- this.environments = environments;
522
- this.http = http;
523
- }
524
- /**
525
- * Retrieves the API URL for open-items from the environments' configuration.
526
- *
527
- * @return {string} The API URL for open-items.
528
- */
529
- get url() {
530
- return this.environments.apiOpenItemsUrl;
531
- }
532
- /**
533
- * Retrieves a list of open-items based on the provided query parameters.
534
- *
535
- * @param {QueryParams} params - The parameters to use for querying open-items.
536
- * @return {Observable<OpenItemsOut>} An observable that emits the open-item's data.
537
- */
538
- getOpenItems(params) {
539
- return this.http.get(`${this.url}/open-items`, { params })
540
- .pipe(map(({ data }) => data));
541
- }
542
- /**
543
- * Processes a payment for an open item.
544
- *
545
- * @param {PaymentOpenItemIn} body - The payment details for the open item.
546
- * @return {Observable<PaymentOpenItemOut>} An observable that emits the result of the payment processing.
547
- */
548
- paymentOpenItem(body) {
549
- return this.http.post(`${this.url}/payment`, body)
550
- .pipe(map(({ data }) => data));
551
- }
552
- /**
553
- * Processes a payment for other invoice.
554
- *
555
- * @param {PaymentOtherInvoiceIn} body - The payment details for the other invoice.
556
- * @return {Observable<PaymentOtherInvoiceOut>} An observable that emits the result of the payment processing.
557
- */
558
- paymentOtherInvoice(body) {
559
- return this.http.post(`${this.url}/other-invoices`, body)
560
- .pipe(map(({ data }) => data));
561
- }
562
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
563
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, providedIn: 'root' });
435
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
436
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
564
437
  }
565
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiOpenItemsService, decorators: [{
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiInvoicesService, decorators: [{
566
439
  type: Injectable,
567
440
  args: [{
568
441
  providedIn: 'root'
@@ -598,46 +471,10 @@ class ApiReportsService {
598
471
  params
599
472
  }).pipe(map(({ data }) => data));
600
473
  }
601
- /**
602
- * Fetches the list of shipments with pending payments.
603
- *
604
- * @param {ExistPendingPaymentsIn} params - The parameters to filter pending payment shipments.
605
- * @return {Observable<ShipmentsReportOut>} An observable emitting the shipments report data.
606
- */
607
- shipmentsPendingPayments(params) {
608
- return this.http.get(`${this.url}/shipments-report`, {
609
- params: {
610
- ...params,
611
- limit: 1,
612
- offset: 0,
613
- to_landing: true,
614
- shipment_status_code: 'PMPEN',
615
- },
616
- }).pipe(map(({ data }) => data));
617
- }
618
- /**
619
- * Fetches shipment reports that are pending invoices based on the specified parameters.
620
- * This method retrieves a filtered list of shipments with pending invoice statuses.
621
- *
622
- * @param {ExistPendingInvoicesIn} params - The parameters to filter the pending invoices, including
623
- * shipment status codes, and pagination options.
624
- * @return {Observable<ShipmentsReportOut>} An observable that emits the shipment report data based on the filter criteria.
625
- */
626
- shipmentsPendingInvoices(params) {
627
- return this.http.get(`${this.url}/shipments-report`, {
628
- params: {
629
- ...params,
630
- limit: 1,
631
- offset: 0,
632
- to_landing: true,
633
- 'shipment_status_code[in]': 'IPMPE,IMPEN,IPPEN',
634
- },
635
- }).pipe(map(({ data }) => data));
636
- }
637
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
638
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
474
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
475
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
639
476
  }
640
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, decorators: [{
477
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiReportsService, decorators: [{
641
478
  type: Injectable,
642
479
  args: [{
643
480
  providedIn: 'root'
@@ -834,36 +671,10 @@ class ApiSecurityService {
834
671
  return this.http.delete(`${this.url}/roles/${id}`)
835
672
  .pipe(map(({ data }) => data));
836
673
  }
837
- /**
838
- * Retrieves a list of modules and permissions
839
- *
840
- * @param queryParams - The query parameters to filter the modules.
841
- * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
842
- */
843
- getModules(queryParams) {
844
- return this.http.get(`${this.url}/modules`, {
845
- params: queryParams
846
- }).pipe(map(({ data }) => data));
847
- }
848
- /**
849
- * Retrieves a list of modules and permissions
850
- *
851
- * @param params.token - Custom token for authorization.
852
- * @param params.queryParams - The query parameters to filter the modules.
853
- * @returns Observable<ModulesOut[]> - An observable that emits an array of modules and permissions.
854
- */
855
- getModulesToken(params) {
856
- return this.http.get(`${this.url}/modules`, {
857
- params: params.queryParams,
858
- headers: {
859
- Authorization: `Bearer ${params.token}`
860
- }
861
- }).pipe(map(({ data }) => data));
862
- }
863
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
864
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
674
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, deps: [{ token: 'env' }, { token: i1$1.CookieService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
675
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
865
676
  }
866
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, decorators: [{
677
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiSecurityService, decorators: [{
867
678
  type: Injectable,
868
679
  args: [{
869
680
  providedIn: 'root'
@@ -899,20 +710,10 @@ class ApiShipmentsService {
899
710
  return this.http.post(`${this.url}/accounts`, body)
900
711
  .pipe(map(({ data }) => data));
901
712
  }
902
- /**
903
- * Sends a POST request to the shipments manifest endpoint with the provided body.
904
- *
905
- * @param body - The request payload of type `ManifestMultipleIn`.
906
- * @returns An observable that emits the response data of type `ManifestMultipleOut`.
907
- */
908
- manifestMultiple(body) {
909
- return this.http.post(`${this.url}/shipments/manifest`, body)
910
- .pipe(map(({ data }) => data));
911
- }
912
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
913
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
713
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
714
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
914
715
  }
915
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, decorators: [{
716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ApiShipmentsService, decorators: [{
916
717
  type: Injectable,
917
718
  args: [{
918
719
  providedIn: 'root'
@@ -922,117 +723,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
922
723
  args: ['env']
923
724
  }] }, { type: i1.HttpClient }] });
924
725
 
925
- class WebSocketsService {
926
- environments;
927
- pusher;
928
- constructor(environments) {
929
- this.environments = environments;
930
- this.pusher = null;
931
- this.connect()
932
- .then((pusher) => {
933
- if (!pusher)
934
- return;
935
- this.pusher = pusher;
936
- });
937
- }
938
- /**
939
- * Publishes an event to the specified channel with the given data.
940
- *
941
- * @param {Channel} channel - The channel instance where the event will be published.
942
- * @param {string} eventName - The name of the event to be published.
943
- * @param {T} data - The payload data to be sent with the event.
944
- * @return {Promise<boolean>} A promise that resolves to a boolean indicating
945
- * whether the event was successfully triggered on the channel.
946
- */
947
- async pub(channel, eventName, data) {
948
- return channel.trigger(`client-${eventName}`, data);
949
- }
950
- /**
951
- * Subscribes to a specified channel, retrying multiple times upon failure.
952
- *
953
- * @param {string} channelName - The name of the channel to be subscribed to.
954
- * @return {Promise<Channel>} A promise that resolves to the subscribed channel object if successful.
955
- * @throws {Error} If the subscription fails after the maximum number of retry attempts.
956
- */
957
- async channelSub(channelName) {
958
- const attempts = 3;
959
- for (let attempt = 0; attempt <= attempts; attempt++) {
960
- const channel = this.pusher?.channel(channelName);
961
- if (channel?.subscribed) {
962
- return channel;
963
- }
964
- this.pusher?.subscribe(channelName);
965
- if (attempt < attempts) {
966
- await this.wait();
967
- }
968
- }
969
- throw new Error(`Failed to subscribe to channel "${channelName}" after ${attempts} attempts.`);
970
- }
971
- /**
972
- * Binds an event listener to a specified event on a given channel using Pusher or a Channel object,
973
- * and returns an Observable that emits event data of type T.
974
- *
975
- * @param {Channel|string} channel - The channel to bind the event to. It can be a Channel object or a string representing the channel name.
976
- * @param {string} event - The name of the event to bind to the channel.
977
- * @return {Observable<T>} An Observable that emits data of type T when the specified event is triggered.
978
- */
979
- eventBind(channel, event) {
980
- return new Observable((subscriber) => {
981
- if (channel?.name) {
982
- channel.bind(event, (data) => subscriber.next(data));
983
- }
984
- else {
985
- this.pusher?.subscribe(channel)
986
- .bind(event, (data) => subscriber.next(data));
987
- }
988
- });
989
- }
990
- /**
991
- * Unbinds an event from the specified channel and returns an observable
992
- * that emits data when the event callback is triggered.
993
- *
994
- * @param {Channel} channel - The channel object from which the event should be unbound.
995
- * @param {string} event - The name of the event to unbind.
996
- * @return {Observable<T>} An observable that emits data from the unbound event callback.
997
- */
998
- eventUnbind(channel, event) {
999
- return new Observable((subscriber) => channel.unbind(event, (data) => subscriber.next(data)));
1000
- }
1001
- connect() {
1002
- return new Promise((resolve) => {
1003
- const { sockets } = this.environments;
1004
- if (!sockets)
1005
- return resolve(false);
1006
- const pusher = new Pusher__default(sockets.app_key, {
1007
- wsHost: sockets.url,
1008
- wsPort: sockets.port,
1009
- enabledTransports: ['wss', 'ws'],
1010
- forceTLS: false,
1011
- enableStats: false,
1012
- });
1013
- if (sockets.debug) {
1014
- Pusher__default.logToConsole = true;
1015
- }
1016
- return resolve(pusher);
1017
- });
1018
- }
1019
- async wait() {
1020
- const waitTime = 3 * 1000;
1021
- return new Promise((resolve) => setTimeout(resolve, waitTime));
1022
- }
1023
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1024
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, providedIn: 'root' });
1025
- }
1026
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: WebSocketsService, decorators: [{
1027
- type: Injectable,
1028
- args: [{
1029
- providedIn: 'root',
1030
- }]
1031
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1032
- type: Inject,
1033
- args: ['env']
1034
- }] }] });
1035
-
1036
726
  class CryptoService {
1037
727
  environments;
1038
728
  constructor(environments) {
@@ -1111,10 +801,10 @@ class CryptoService {
1111
801
  }
1112
802
  return bytes.buffer;
1113
803
  }
1114
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1115
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, providedIn: 'root' });
804
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
805
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, providedIn: 'root' });
1116
806
  }
1117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: CryptoService, decorators: [{
807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: CryptoService, decorators: [{
1118
808
  type: Injectable,
1119
809
  args: [{
1120
810
  providedIn: 'root'
@@ -1124,124 +814,86 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
1124
814
  args: ['env']
1125
815
  }] }] });
1126
816
 
1127
- class ApiHeadersInterceptor {
1128
- /**
1129
- * Intercepts HTTP requests and modifies request headers to include caching, content type,
1130
- * accept language, and other HTTP-specific configurations before forwarding the request onward.
1131
- *
1132
- * @param {HttpRequest<unknown>} request - The HTTP request instance to be intercepted and modified.
1133
- * @param {HttpHandler} next - The next handler instance in the HTTP pipeline which processes
1134
- * the modified request and forwards it.
1135
- * @return {Observable<HttpEvent<unknown>>} An observable of the processed HTTP event.
1136
- */
1137
- intercept(request, next) {
1138
- let headers = new HttpHeaders({
1139
- 'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
1140
- expires: '0',
1141
- pragma: 'no-cache'
1142
- });
1143
- if (!request.headers.has('Content-Type')) {
1144
- headers = headers.set('Content-Type', 'application/json');
1145
- }
1146
- if (!request.headers.has('Accept')) {
1147
- headers = headers.set('Accept', 'application/json');
1148
- }
1149
- if (!request.headers.has('Accept-Language')) {
1150
- headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
1151
- }
1152
- request = request.clone({ headers });
1153
- return next.handle(request);
817
+ /**
818
+ * Intercepts an outgoing HTTP request and modifies its headers to include default values
819
+ * for Cache-Control, Expires, Pragma, Content-Type, Accept, and Accept-Language if they
820
+ * are not already present.
821
+ *
822
+ * @param {HttpRequest<unknown>} req - The outgoing HTTP request to be intercepted and modified.
823
+ * @param {HttpHandlerFn} next - The next handler in the chain to pass the modified request to.
824
+ * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event resulting from the processed request.
825
+ */
826
+ function apiHeadersInterceptor(req, next) {
827
+ let { headers } = req;
828
+ if (!headers.has('Content-Type')) {
829
+ headers = headers.set('Content-Type', 'application/json');
830
+ }
831
+ if (!headers.has('Accept')) {
832
+ headers = headers.set('Accept', 'application/json');
1154
833
  }
1155
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1156
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor });
834
+ if (!headers.has('Accept-Language')) {
835
+ headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
836
+ }
837
+ req = req.clone({ headers });
838
+ return next(req);
1157
839
  }
1158
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiHeadersInterceptor, decorators: [{
1159
- type: Injectable
1160
- }] });
1161
840
 
1162
- class ApiTokenInterceptor {
1163
- environments;
1164
- cookie;
1165
- constructor(environments, cookie) {
1166
- this.environments = environments;
1167
- this.cookie = cookie;
1168
- }
1169
- /**
1170
- * Intercepts and modifies the outgoing HTTP request to include an authorization token
1171
- * from cookies if the request does not already have an Authorization or AppKey header.
1172
- *
1173
- * @param {HttpRequest<unknown>} request - The outgoing HTTP request to be intercepted.
1174
- * @param {HttpHandler} next - The next handler in the HTTP request processing chain.
1175
- * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event, modified or unmodified.
1176
- */
1177
- intercept(request, next) {
1178
- if (request.headers.has('Authorization') || request.headers.has('AppKey')) {
1179
- return next.handle(request);
841
+ /**
842
+ * An HTTP interceptor to append an Authorization header with a Bearer token
843
+ * to outgoing HTTP requests if certain conditions are met.
844
+ *
845
+ * @param {HttpRequest<unknown>} req - The outgoing HTTP request object which may be modified.
846
+ * @param {HttpHandlerFn} next - The next handler in the HTTP request pipeline.
847
+ * @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event stream resulting from the request.
848
+ */
849
+ function apiTokenInterceptor(req, next) {
850
+ const { authCookie } = inject(ENVIRONMENT_TOKEN);
851
+ const cookie = inject(CookieService);
852
+ if (req.headers.has('Authorization') || req.headers.has('AppKey')) {
853
+ return next(req);
854
+ }
855
+ const token = cookie.get(authCookie);
856
+ if (!token)
857
+ return next(req);
858
+ req = req.clone({
859
+ setHeaders: {
860
+ Authorization: `Bearer ${token}`
1180
861
  }
1181
- const token = this.cookie.get(this.environments.authCookie);
1182
- if (!token)
1183
- return next.handle(request);
1184
- request = request.clone({
1185
- setHeaders: {
1186
- Authorization: `Bearer ${token}`
1187
- }
1188
- });
1189
- return next.handle(request);
1190
- }
1191
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor, deps: [{ token: 'env' }, { token: i1$1.CookieService }], target: i0.ɵɵFactoryTarget.Injectable });
1192
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor });
862
+ });
863
+ return next(req);
1193
864
  }
1194
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiTokenInterceptor, decorators: [{
1195
- type: Injectable
1196
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1197
- type: Inject,
1198
- args: ['env']
1199
- }] }, { type: i1$1.CookieService }] });
1200
865
 
1201
866
  const DEFAULT_TTL = 10000; // ttl in ms
1202
- class HttpCachingInterceptor {
1203
- envs;
1204
- cache = new Map();
1205
- constructor(envs) {
1206
- this.envs = envs;
1207
- }
1208
- /**
1209
- * Intercepts HTTP requests to add caching functionality for GET requests.
1210
- * Non-GET requests are passed through without caching.
1211
- *
1212
- * @param {HttpRequest<any>} req - The HTTP request being intercepted.
1213
- * @param {HttpHandler} next - The next handler in the HTTP pipeline to execute the request.
1214
- * @return {Observable<HttpEvent<any>>} - An observable containing the HTTP response event, either from cache or the backend service.
1215
- */
1216
- intercept(req, next) {
1217
- if (req.method !== 'GET') {
1218
- return next.handle(req);
1219
- }
1220
- const cached = this.cache.get(req.urlWithParams);
1221
- if (cached) {
1222
- const isExpired = Date.now() > cached.ttl;
1223
- if (!isExpired) {
1224
- return of(cached.res);
1225
- }
1226
- this.cache.delete(req.urlWithParams); // If expired, remove the entry from cache
867
+ const cache = new Map();
868
+ /**
869
+ * Interceptor function to handle HTTP caching for GET requests. It retrieves cached responses
870
+ * if available and valid; otherwise, it processes the request and caches the response for future use.
871
+ *
872
+ * @param {HttpRequest<any>} req - The HTTP request object being intercepted.
873
+ * @param {HttpHandlerFn} next - The next HTTP handler function in the chain to process the request.
874
+ * @return {Observable<HttpEvent<any>>} An observable that emits the HTTP event, either from cache
875
+ * or by invoking the next handler.
876
+ */
877
+ function httpCachingInterceptor(req, next) {
878
+ const { cacheTtl } = inject(ENVIRONMENT_TOKEN);
879
+ if (req.method !== 'GET')
880
+ return next(req);
881
+ const cached = cache.get(req.urlWithParams);
882
+ if (cached) {
883
+ const isExpired = Date.now() > cached.ttl;
884
+ if (!isExpired) {
885
+ return of(cached.res);
1227
886
  }
1228
- return next.handle(req).pipe(tap$1((res) => {
1229
- if (!(res instanceof HttpResponse)) {
1230
- return;
1231
- }
1232
- const ttl = Date.now() + (this.envs.cacheTtl ?? DEFAULT_TTL);
1233
- this.cache.set(req.urlWithParams, { res, ttl });
1234
- }));
887
+ cache.delete(req.urlWithParams); // If expired, remove the entry from cache
1235
888
  }
1236
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, deps: [{ token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
1237
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor });
889
+ return next(req).pipe(tap$1((res) => {
890
+ if (!(res instanceof HttpResponse)) {
891
+ return;
892
+ }
893
+ const ttl = Date.now() + (cacheTtl ?? DEFAULT_TTL);
894
+ cache.set(req.urlWithParams, { res, ttl });
895
+ }));
1238
896
  }
1239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: HttpCachingInterceptor, decorators: [{
1240
- type: Injectable
1241
- }], ctorParameters: () => [{ type: undefined, decorators: [{
1242
- type: Inject,
1243
- args: ['env']
1244
- }] }] });
1245
897
 
1246
898
  /*
1247
899
  * Public API Surface of ngx-services
@@ -1251,5 +903,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
1251
903
  * Generated bundle index. Do not edit.
1252
904
  */
1253
905
 
1254
- export { ApiCompaniesService, ApiExternalPickupsService, ApiHeadersInterceptor, ApiInvoicesService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiShipmentsService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, WebSocketsService, httpParams, pdfHeaders, queryString, xmlHeaders };
906
+ export { ApiCompaniesService, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, CryptoService, ENVIRONMENT_TOKEN, NgxServicesModule, apiHeadersInterceptor, apiTokenInterceptor, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
1255
907
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map