@experteam-mx/ngx-services 20.9.8 → 20.10.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, makeEnvironmentProviders, NgModule, inject, Injectable } from '@angular/core';
|
|
3
3
|
import { provideHttpClient, HttpClient, HttpHeaders, HttpResponse, HttpParams } from '@angular/common/http';
|
|
4
|
-
import { map, mergeMap, forkJoin, tap, BehaviorSubject,
|
|
4
|
+
import { map, mergeMap, forkJoin, tap, BehaviorSubject, firstValueFrom, Observable, of } from 'rxjs';
|
|
5
5
|
import { map as map$1, tap as tap$1, finalize, shareReplay } from 'rxjs/operators';
|
|
6
6
|
import { CookieService } from 'ngx-cookie-service';
|
|
7
7
|
import Pusher from 'pusher-js';
|
|
@@ -1903,6 +1903,19 @@ class ApiCompaniesService {
|
|
|
1903
1903
|
return this.http.delete(`${this.url}/employees/${id}`)
|
|
1904
1904
|
.pipe(map(({ data }) => data));
|
|
1905
1905
|
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Exports the filtered employees list as a PDF file.
|
|
1908
|
+
*
|
|
1909
|
+
* @param {QueryParams} params - Query parameters used to filter the employees included in the export.
|
|
1910
|
+
* @return {Observable<HttpResponse<ArrayBuffer>>} An observable that emits the HTTP response containing the PDF as an ArrayBuffer.
|
|
1911
|
+
*/
|
|
1912
|
+
getEmployeesExportPdf(params) {
|
|
1913
|
+
return this.http.get(`${this.url}/employees/exportPdf`, {
|
|
1914
|
+
params,
|
|
1915
|
+
observe: 'response',
|
|
1916
|
+
responseType: 'arraybuffer'
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1906
1919
|
/**
|
|
1907
1920
|
* Retrieves the list of employees for a specified location based on provided query parameters.
|
|
1908
1921
|
*
|
|
@@ -2935,6 +2948,26 @@ class ApiCustomsService {
|
|
|
2935
2948
|
params
|
|
2936
2949
|
}).pipe(map(({ data }) => data));
|
|
2937
2950
|
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Retrieves the documents for a specific country.
|
|
2953
|
+
*
|
|
2954
|
+
* @param {DocumentsByCountryIn} body - The body of the request.
|
|
2955
|
+
* @return {Observable<DocumentsByCountryOut>} An Observable that emits the documents.
|
|
2956
|
+
*/
|
|
2957
|
+
postDocumentsByCountry(body) {
|
|
2958
|
+
return this.http.post(`${this.url}/documents/by-country`, body)
|
|
2959
|
+
.pipe(map(({ data }) => data));
|
|
2960
|
+
}
|
|
2961
|
+
/**
|
|
2962
|
+
* Prints a document for a specific country and code.
|
|
2963
|
+
*
|
|
2964
|
+
* @param {DocumentsPrintIn} body - The body of the request.
|
|
2965
|
+
* @return {Observable<DocumentsPrintOut>} An Observable that emits the printed document.
|
|
2966
|
+
*/
|
|
2967
|
+
postDocumentsPrint(body) {
|
|
2968
|
+
return this.http.post(`${this.url}/documents/print`, body)
|
|
2969
|
+
.pipe(map(({ data }) => data));
|
|
2970
|
+
}
|
|
2938
2971
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiCustomsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2939
2972
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiCustomsService, providedIn: 'root' });
|
|
2940
2973
|
}
|
|
@@ -2966,6 +2999,36 @@ class ApiDiscountsService {
|
|
|
2966
2999
|
return this.http.get(`${this.url}/discounts`, { params })
|
|
2967
3000
|
.pipe(map(({ data }) => data));
|
|
2968
3001
|
}
|
|
3002
|
+
/**
|
|
3003
|
+
* Retrieves a list of active discounts.
|
|
3004
|
+
*
|
|
3005
|
+
* @param {QueryParams} [params] - Optional query parameters to filter active discounts.
|
|
3006
|
+
* @return {Observable<DiscountsOut>} An Observable that emits the active discounts data.
|
|
3007
|
+
*/
|
|
3008
|
+
getDiscountsActives(params) {
|
|
3009
|
+
return this.http.get(`${this.url}/discounts/actives`, { params })
|
|
3010
|
+
.pipe(map(({ data }) => data));
|
|
3011
|
+
}
|
|
3012
|
+
/**
|
|
3013
|
+
* Searches for a customer by identification, phone, or email (Version 2).
|
|
3014
|
+
*
|
|
3015
|
+
* @param {OperationsSearchCustomerV2In} body - The search criteria for the customer.
|
|
3016
|
+
* @return {Observable<OperationsSearchCustomerV2Out>} An Observable that emits the search result.
|
|
3017
|
+
*/
|
|
3018
|
+
postOperationsSearchCustomerV2(body) {
|
|
3019
|
+
return this.http.post(`${this.url}/operations/search-customer/V2`, body)
|
|
3020
|
+
.pipe(map(({ data }) => data));
|
|
3021
|
+
}
|
|
3022
|
+
/**
|
|
3023
|
+
* Creates a registered customer (Version 2).
|
|
3024
|
+
*
|
|
3025
|
+
* @param {RegisteredCustomerIn} body - The registered customer data to create.
|
|
3026
|
+
* @return {Observable<RegisteredCustomerOut>} An Observable that emits the created registered customer.
|
|
3027
|
+
*/
|
|
3028
|
+
postRegisteredCustomersV2(body) {
|
|
3029
|
+
return this.http.post(`${this.url}/registered-customers/V2`, body)
|
|
3030
|
+
.pipe(map(({ data }) => data));
|
|
3031
|
+
}
|
|
2969
3032
|
/**
|
|
2970
3033
|
* Sends a request to create or update discounts on the server.
|
|
2971
3034
|
*
|
|
@@ -3203,6 +3266,27 @@ class ApiDropoffsService {
|
|
|
3203
3266
|
postShipmentsEReceipt(body) {
|
|
3204
3267
|
return this.http.post(`${this.url}/shipments/ereceipt`, body).pipe(map(({ data }) => data));
|
|
3205
3268
|
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Retrieves the check-in print payload for the given operation.
|
|
3271
|
+
*
|
|
3272
|
+
* @param {number} operationId - The unique identifier of the check-in operation to print.
|
|
3273
|
+
* @param {QueryParams} params - The query parameters used to customize the print request.
|
|
3274
|
+
* @return {Observable<CheckInPrintOut>} An observable that emits the check-in print data.
|
|
3275
|
+
*/
|
|
3276
|
+
getCheckInPrint(operationId, params) {
|
|
3277
|
+
return this.http.get(`${this.url}/check-in/print/${operationId}`, { params })
|
|
3278
|
+
.pipe(map(({ data }) => data));
|
|
3279
|
+
}
|
|
3280
|
+
/**
|
|
3281
|
+
* Retrieves the printable ticket payload for the given dropoff operation.
|
|
3282
|
+
*
|
|
3283
|
+
* @param {number} operationId - The unique identifier of the operation.
|
|
3284
|
+
* @return {Observable<OperationTicketsOut>} An observable that emits the operation ticket data.
|
|
3285
|
+
*/
|
|
3286
|
+
getOperationTickets(operationId) {
|
|
3287
|
+
return this.http.get(`${this.url}/operations/${operationId}/tickets`)
|
|
3288
|
+
.pipe(map(({ data }) => data));
|
|
3289
|
+
}
|
|
3206
3290
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiDropoffsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3207
3291
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiDropoffsService, providedIn: 'root' });
|
|
3208
3292
|
}
|
|
@@ -3891,8 +3975,8 @@ class ApiInvoicesService {
|
|
|
3891
3975
|
* @param documentId - Numeric identifier of the document to print.
|
|
3892
3976
|
* @returns An Observable that emits the ticket data for the given document.
|
|
3893
3977
|
*/
|
|
3894
|
-
getOperationPrintTicket(documentId) {
|
|
3895
|
-
return this.http.get(`${this.url}/operation/print/ticket/${documentId}
|
|
3978
|
+
getOperationPrintTicket(documentId, params) {
|
|
3979
|
+
return this.http.get(`${this.url}/operation/print/ticket/${documentId}`, { params })
|
|
3896
3980
|
.pipe(map(({ data }) => data));
|
|
3897
3981
|
}
|
|
3898
3982
|
/**
|
|
@@ -3924,7 +4008,7 @@ class ApiInvoicesService {
|
|
|
3924
4008
|
* @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
|
|
3925
4009
|
* @return {Observable<PrintCollectionReceiptOut>} An observable containing the collection receipt data.
|
|
3926
4010
|
*/
|
|
3927
|
-
|
|
4011
|
+
getOperationPrintCollectionReceipt(id) {
|
|
3928
4012
|
return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
|
|
3929
4013
|
.pipe(map(({ data }) => data));
|
|
3930
4014
|
}
|
|
@@ -5315,6 +5399,26 @@ class ApiShipmentsService {
|
|
|
5315
5399
|
return this.http.get(`${this.url}/shipments/${id}/documents`)
|
|
5316
5400
|
.pipe(map(({ data }) => data));
|
|
5317
5401
|
}
|
|
5402
|
+
/**
|
|
5403
|
+
* Retrieves the label for a specific shipment
|
|
5404
|
+
* @param {number} shipmentId - The unique identifier of the shipment to retrieve the label for
|
|
5405
|
+
* @returns {Observable<ShipmentLabelOut>} Observable containing the label for the shipment
|
|
5406
|
+
*/
|
|
5407
|
+
getShipmentLabel(shipmentId, format = 'pdf') {
|
|
5408
|
+
return this.http.get(`${this.url}/shipments/${shipmentId}/label/${format}`)
|
|
5409
|
+
.pipe(map(({ data }) => data));
|
|
5410
|
+
}
|
|
5411
|
+
/**
|
|
5412
|
+
* Generates a commercial invoice label for the specified shipment.
|
|
5413
|
+
*
|
|
5414
|
+
* @param {number} shipmentId - The unique identifier of the shipment.
|
|
5415
|
+
* @param {CommercialInvoiceLabelIn} body - Payload containing the invoice label date.
|
|
5416
|
+
* @returns {Observable<CommercialInvoiceLabelOut>} Observable emitting the generated commercial invoice label for the shipment.
|
|
5417
|
+
*/
|
|
5418
|
+
postCommercialInvoiceLabel(shipmentId, body) {
|
|
5419
|
+
return this.http.post(`${this.url}/commercial-invoice-labels/${shipmentId}`, body)
|
|
5420
|
+
.pipe(map(({ data }) => data));
|
|
5421
|
+
}
|
|
5318
5422
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiShipmentsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5319
5423
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.27", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
|
|
5320
5424
|
}
|
|
@@ -5611,11 +5715,11 @@ var PrintersType;
|
|
|
5611
5715
|
})(PrintersType || (PrintersType = {}));
|
|
5612
5716
|
|
|
5613
5717
|
class PrintersService {
|
|
5614
|
-
environments = inject(ENVIRONMENT_TOKEN);
|
|
5615
5718
|
http = inject(HttpClient);
|
|
5616
5719
|
availablePrinters$ = new BehaviorSubject([]);
|
|
5617
|
-
printMode = PrintMode.DISPLAY;
|
|
5618
5720
|
printers = [];
|
|
5721
|
+
printMode = PrintMode.DISPLAY;
|
|
5722
|
+
printServiceUrl = '';
|
|
5619
5723
|
/**
|
|
5620
5724
|
* Retrieves the print URL from the environments configuration or defaults to 'http://localhost:9100'
|
|
5621
5725
|
* if not specified.
|
|
@@ -5623,7 +5727,15 @@ class PrintersService {
|
|
|
5623
5727
|
* @return {string} The URL to be used for printing.
|
|
5624
5728
|
*/
|
|
5625
5729
|
get url() {
|
|
5626
|
-
return this.
|
|
5730
|
+
return this.printServiceUrl || 'http://localhost:9100';
|
|
5731
|
+
}
|
|
5732
|
+
/**
|
|
5733
|
+
* Indicates whether any configured printers are available for use.
|
|
5734
|
+
*
|
|
5735
|
+
* @return {boolean} Returns true if at least one printer is configured; otherwise, false.
|
|
5736
|
+
*/
|
|
5737
|
+
get usingPrinters() {
|
|
5738
|
+
return this.printers.some((printer) => printer.configured);
|
|
5627
5739
|
}
|
|
5628
5740
|
/**
|
|
5629
5741
|
* Prints or displays a document based on the current print mode.
|
|
@@ -5633,9 +5745,9 @@ class PrintersService {
|
|
|
5633
5745
|
* @param {Printable} document - The document to be printed or displayed.
|
|
5634
5746
|
* @return {Promise<void>} A promise that resolves when the printing or displaying process is complete, or rejects if an error occurs.
|
|
5635
5747
|
*/
|
|
5636
|
-
print(document) {
|
|
5748
|
+
print(document, printMode = this.printMode) {
|
|
5637
5749
|
return new Promise((resolve, reject) => {
|
|
5638
|
-
switch (
|
|
5750
|
+
switch (printMode) {
|
|
5639
5751
|
case PrintMode.PRINT:
|
|
5640
5752
|
this.sendToPrinter(document).then(() => resolve()).catch(reject);
|
|
5641
5753
|
break;
|
|
@@ -5643,13 +5755,11 @@ class PrintersService {
|
|
|
5643
5755
|
this.sendToBrowser(document).then(resolve).catch(reject);
|
|
5644
5756
|
break;
|
|
5645
5757
|
case PrintMode.BOTH:
|
|
5646
|
-
|
|
5758
|
+
Promise.all([
|
|
5647
5759
|
this.sendToBrowser(document),
|
|
5648
5760
|
this.sendToPrinter(document)
|
|
5649
|
-
]).
|
|
5650
|
-
|
|
5651
|
-
error: reject,
|
|
5652
|
-
});
|
|
5761
|
+
]).then(() => resolve())
|
|
5762
|
+
.catch(reject);
|
|
5653
5763
|
break;
|
|
5654
5764
|
}
|
|
5655
5765
|
});
|
|
@@ -5662,8 +5772,9 @@ class PrintersService {
|
|
|
5662
5772
|
* @param {PrintMode} config.printMode - The mode of printing, defining whether to use print, digital, or both.
|
|
5663
5773
|
* @return {void} This method does not return any value.
|
|
5664
5774
|
*/
|
|
5665
|
-
setUp({ country, printMode }) {
|
|
5775
|
+
setUp({ country, printMode, printServiceUrl }) {
|
|
5666
5776
|
this.printMode = printMode;
|
|
5777
|
+
this.printServiceUrl = printServiceUrl || '';
|
|
5667
5778
|
if (this.printMode === PrintMode.BOTH || this.printMode === PrintMode.PRINT) {
|
|
5668
5779
|
this.checkPrinters(country);
|
|
5669
5780
|
}
|
|
@@ -5678,10 +5789,9 @@ class PrintersService {
|
|
|
5678
5789
|
setDown() {
|
|
5679
5790
|
this.printers = [];
|
|
5680
5791
|
this.availablePrinters$.next(this.printers);
|
|
5681
|
-
this.availablePrinters$.complete();
|
|
5682
5792
|
}
|
|
5683
5793
|
sendToPrinter({ type, content, format }) {
|
|
5684
|
-
const printer = this.printers.find((
|
|
5794
|
+
const printer = this.printers.find((printer) => printer.type === type && printer.configured);
|
|
5685
5795
|
if (!printer) {
|
|
5686
5796
|
throw new Error(`Printer ${type} not found.`);
|
|
5687
5797
|
}
|
|
@@ -5695,7 +5805,7 @@ class PrintersService {
|
|
|
5695
5805
|
return new Promise((resolve, reject) => {
|
|
5696
5806
|
try {
|
|
5697
5807
|
if (format === PrintableFormat.ZPL2) {
|
|
5698
|
-
return;
|
|
5808
|
+
return resolve();
|
|
5699
5809
|
}
|
|
5700
5810
|
downloadBase64Pdf(content);
|
|
5701
5811
|
resolve();
|
|
@@ -5706,22 +5816,26 @@ class PrintersService {
|
|
|
5706
5816
|
});
|
|
5707
5817
|
}
|
|
5708
5818
|
checkPrinters(country) {
|
|
5819
|
+
this.printers = [];
|
|
5709
5820
|
if (country.label_printer_name) {
|
|
5710
5821
|
this.printers.push({
|
|
5711
|
-
name: PrintersType.LABEL,
|
|
5712
5822
|
configured: false,
|
|
5823
|
+
name: country.label_printer_name,
|
|
5824
|
+
type: PrintersType.LABEL,
|
|
5713
5825
|
});
|
|
5714
5826
|
}
|
|
5715
5827
|
if (country.receipt_printer_name) {
|
|
5716
5828
|
this.printers.push({
|
|
5717
|
-
name: PrintersType.RECEIPT,
|
|
5718
5829
|
configured: false,
|
|
5830
|
+
name: country.receipt_printer_name,
|
|
5831
|
+
type: PrintersType.RECEIPT,
|
|
5719
5832
|
});
|
|
5720
5833
|
}
|
|
5721
5834
|
if (country.others_printer_name) {
|
|
5722
5835
|
this.printers.push({
|
|
5723
|
-
name: PrintersType.OTHERS,
|
|
5724
5836
|
configured: false,
|
|
5837
|
+
name: country.others_printer_name,
|
|
5838
|
+
type: PrintersType.OTHERS,
|
|
5725
5839
|
});
|
|
5726
5840
|
}
|
|
5727
5841
|
this.http.get(`${this.url}/available`)
|