@experteam-mx/ngx-services 18.2.0 → 18.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/apis/api-companies.service.mjs +35 -24
- package/esm2022/lib/apis/api-invoices.service.mjs +74 -0
- package/esm2022/lib/apis/api-reports.service.mjs +43 -0
- package/esm2022/lib/apis/api-security.service.mjs +66 -2
- package/esm2022/lib/apis/api-shipments.service.mjs +43 -0
- package/esm2022/lib/apis/models/api-companies.interfaces.mjs +1 -1
- package/esm2022/lib/apis/models/api-companies.types.mjs +1 -1
- package/esm2022/lib/apis/models/api-invoices.interfaces.mjs +2 -0
- package/esm2022/lib/apis/models/api-invoices.types.mjs +2 -0
- package/esm2022/lib/apis/models/api-reports.interfaces.mjs +2 -0
- package/esm2022/lib/apis/models/api-reports.types.mjs +2 -0
- package/esm2022/lib/apis/models/api-security.interfaces.mjs +1 -1
- package/esm2022/lib/apis/models/api-security.types.mjs +1 -1
- package/esm2022/lib/apis/models/api-shipments.types.mjs +2 -0
- package/esm2022/lib/apis/models/api.models.mjs +1 -1
- package/esm2022/lib/cypher/crypto.service.mjs +4 -3
- package/esm2022/lib/helpers/http.mjs +4 -4
- package/esm2022/lib/interceptors/api-headers.interceptor.mjs +15 -11
- package/esm2022/lib/interceptors/api-token.interceptor.mjs +8 -7
- package/esm2022/lib/interceptors/http-caching.interceptor.mjs +15 -4
- package/esm2022/lib/ngx-services.models.mjs +1 -1
- package/esm2022/public-api.mjs +9 -2
- package/fesm2022/experteam-mx-ngx-services.mjs +289 -49
- package/fesm2022/experteam-mx-ngx-services.mjs.map +1 -1
- package/lib/apis/api-companies.service.d.ts +46 -39
- package/lib/apis/api-invoices.service.d.ts +48 -0
- package/lib/apis/api-reports.service.d.ts +26 -0
- package/lib/apis/api-security.service.d.ts +45 -1
- package/lib/apis/api-shipments.service.d.ts +26 -0
- package/lib/apis/models/api-companies.interfaces.d.ts +6 -193
- package/lib/apis/models/api-companies.types.d.ts +30 -22
- package/lib/apis/models/api-invoices.interfaces.d.ts +139 -0
- package/lib/apis/models/api-invoices.types.d.ts +44 -0
- package/lib/apis/models/api-reports.interfaces.d.ts +47 -0
- package/lib/apis/models/api-reports.types.d.ts +6 -0
- package/lib/apis/models/api-security.interfaces.d.ts +18 -7
- package/lib/apis/models/api-security.types.d.ts +27 -4
- package/lib/apis/models/api-shipments.types.d.ts +32 -0
- package/lib/apis/models/api.models.d.ts +5 -0
- package/lib/interceptors/api-headers.interceptor.d.ts +6 -5
- package/lib/interceptors/api-token.interceptor.d.ts +5 -5
- package/lib/interceptors/http-caching.interceptor.d.ts +8 -0
- package/lib/ngx-services.models.d.ts +6 -3
- package/package.json +9 -1
- package/public-api.d.ts +8 -1
|
@@ -44,7 +44,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
|
44
44
|
* @return {string} - The generated query string.
|
|
45
45
|
*/
|
|
46
46
|
const queryString = (params) => {
|
|
47
|
-
|
|
47
|
+
const queryElements = [];
|
|
48
48
|
Object.entries(params).forEach(([key, value]) => {
|
|
49
49
|
if (Array.isArray(value)) {
|
|
50
50
|
const arrayQuery = value
|
|
@@ -79,7 +79,7 @@ const httpParams = (params) => new HttpParams({
|
|
|
79
79
|
*/
|
|
80
80
|
const pdfHeaders = (format = 'object') => {
|
|
81
81
|
const headers = {
|
|
82
|
-
|
|
82
|
+
Accept: 'application/pdf'
|
|
83
83
|
};
|
|
84
84
|
return format === 'object'
|
|
85
85
|
? headers
|
|
@@ -94,7 +94,7 @@ const pdfHeaders = (format = 'object') => {
|
|
|
94
94
|
*/
|
|
95
95
|
const xmlHeaders = (format = 'object') => {
|
|
96
96
|
const headers = {
|
|
97
|
-
|
|
97
|
+
Accept: 'application/xml',
|
|
98
98
|
};
|
|
99
99
|
return format === 'object'
|
|
100
100
|
? headers
|
|
@@ -120,7 +120,7 @@ class ApiCompaniesService {
|
|
|
120
120
|
* Fetches the installations based on the provided query parameters.
|
|
121
121
|
*
|
|
122
122
|
* @param {QueryParams} params - The parameters used to filter the installations query.
|
|
123
|
-
* @return {Observable<
|
|
123
|
+
* @return {Observable<InstallationsOut>} An observable that emits the installation's data.
|
|
124
124
|
*/
|
|
125
125
|
getInstallations(params) {
|
|
126
126
|
return this.http.get(`${this.url}/installations`, {
|
|
@@ -131,7 +131,7 @@ class ApiCompaniesService {
|
|
|
131
131
|
* Retrieves the installation details based on the given installation ID.
|
|
132
132
|
*
|
|
133
133
|
* @param {number} id - The unique identifier of the installation to retrieve.
|
|
134
|
-
* @returns {Observable<
|
|
134
|
+
* @returns {Observable<InstallationOut>} An observable of the installation details.
|
|
135
135
|
*/
|
|
136
136
|
getInstallation(id) {
|
|
137
137
|
return this.http.get(`${this.url}/installations/${id}`)
|
|
@@ -141,7 +141,7 @@ class ApiCompaniesService {
|
|
|
141
141
|
* Retrieves a list of locations based on the provided query parameters.
|
|
142
142
|
*
|
|
143
143
|
* @param {QueryParams} params - The parameters to use for querying locations.
|
|
144
|
-
* @return {Observable<
|
|
144
|
+
* @return {Observable<LocationsOut>} An observable that emits the location's data.
|
|
145
145
|
*/
|
|
146
146
|
getLocations(params) {
|
|
147
147
|
return this.http.get(`${this.url}/locations`, {
|
|
@@ -152,7 +152,7 @@ class ApiCompaniesService {
|
|
|
152
152
|
* Fetches the location details for a given location ID.
|
|
153
153
|
*
|
|
154
154
|
* @param {number} id - The unique identifier of the location.
|
|
155
|
-
* @return {Observable<
|
|
155
|
+
* @return {Observable<LocationOut>} An Observable containing the location details.
|
|
156
156
|
*/
|
|
157
157
|
getLocation(id) {
|
|
158
158
|
return this.http.get(`${this.url}/locations/${id}`)
|
|
@@ -162,7 +162,7 @@ class ApiCompaniesService {
|
|
|
162
162
|
* Retrieves a list of active supply entities.
|
|
163
163
|
*
|
|
164
164
|
* @param {QueryParams} params - The query parameters to filter supply entities.
|
|
165
|
-
* @return {Observable<
|
|
165
|
+
* @return {Observable<SupplyEntitiesOut>} Observable emitting supply entities data.
|
|
166
166
|
*/
|
|
167
167
|
getSupplyEntitiesActive(params) {
|
|
168
168
|
return this.http.get(`${this.url}/supply-entities/actives`, {
|
|
@@ -173,7 +173,7 @@ class ApiCompaniesService {
|
|
|
173
173
|
* Fetches a list of employees based on the specified query parameters.
|
|
174
174
|
*
|
|
175
175
|
* @param {QueryParams} params - The parameters to filter and sort the employees.
|
|
176
|
-
* @return {Observable<
|
|
176
|
+
* @return {Observable<EmployeesOut>} An observable that emits the list of employees.
|
|
177
177
|
*/
|
|
178
178
|
getEmployees(params) {
|
|
179
179
|
return this.http.get(`${this.url}/employees`, {
|
|
@@ -184,7 +184,7 @@ class ApiCompaniesService {
|
|
|
184
184
|
* Fetches an employee's details based on the provided employee ID.
|
|
185
185
|
*
|
|
186
186
|
* @param {number} id - The unique identifier of the employee.
|
|
187
|
-
* @return {Observable<
|
|
187
|
+
* @return {Observable<EmployeeOut>} An observable that emits the employee's details.
|
|
188
188
|
*/
|
|
189
189
|
getEmployee(id) {
|
|
190
190
|
return this.http.get(`${this.url}/employees/${id}`)
|
|
@@ -194,7 +194,7 @@ class ApiCompaniesService {
|
|
|
194
194
|
* Retrieves the list of employees for a specified location based on provided query parameters.
|
|
195
195
|
*
|
|
196
196
|
* @param {QueryParams} params - The query parameters used to filter and retrieve the location employees.
|
|
197
|
-
* @returns {Observable<
|
|
197
|
+
* @returns {Observable<LocationEmployeesOut>} An observable that emits the list of employees for the specified location.
|
|
198
198
|
*/
|
|
199
199
|
getLocationEmployees(params) {
|
|
200
200
|
return this.http.get(`${this.url}/location-employees`, {
|
|
@@ -205,7 +205,7 @@ class ApiCompaniesService {
|
|
|
205
205
|
* Retrieves a list of countries where the company operates.
|
|
206
206
|
*
|
|
207
207
|
* @param {QueryParams} params - The query parameters for the API request.
|
|
208
|
-
* @return {Observable<
|
|
208
|
+
* @return {Observable<CompanyCountriesOut>} An observable containing the list of company countries.
|
|
209
209
|
*/
|
|
210
210
|
getCompanyCountries(params) {
|
|
211
211
|
return this.http.get(`${this.url}/company-countries`, {
|
|
@@ -216,7 +216,7 @@ class ApiCompaniesService {
|
|
|
216
216
|
* Retrieves the country information for a specified company by its ID.
|
|
217
217
|
*
|
|
218
218
|
* @param {number} id - The unique identifier of the company.
|
|
219
|
-
* @return {Observable<
|
|
219
|
+
* @return {Observable<CompanyCountryOut>} An observable containing the country information of the company.
|
|
220
220
|
*/
|
|
221
221
|
getCompanyCountry(id) {
|
|
222
222
|
return this.http.get(`${this.url}/company-countries/${id}`)
|
|
@@ -226,7 +226,7 @@ class ApiCompaniesService {
|
|
|
226
226
|
* Fetches the reference currencies for a given country.
|
|
227
227
|
*
|
|
228
228
|
* @param {QueryParams} params - The query parameters to include in the request.
|
|
229
|
-
* @return {Observable<
|
|
229
|
+
* @return {Observable<CountryReferenceCurrenciesOut>} The observable containing the country reference currencies data.
|
|
230
230
|
*/
|
|
231
231
|
getCountryReferenceCurrencies(params) {
|
|
232
232
|
return this.http.get(`${this.url}/country-reference-currencies`, { params }).pipe(map(({ data }) => data));
|
|
@@ -241,21 +241,32 @@ class ApiCompaniesService {
|
|
|
241
241
|
return this.getCountryReferenceCurrencies(params)
|
|
242
242
|
.pipe(mergeMap((currenciesData) => {
|
|
243
243
|
const $observables = currenciesData.country_reference_currencies
|
|
244
|
-
.map((
|
|
245
|
-
currency_id:
|
|
244
|
+
.map((item) => this.getCurrentExchanges({
|
|
245
|
+
currency_id: item.currency.id,
|
|
246
246
|
}).pipe(map((exchangesData) => ({
|
|
247
|
-
...
|
|
248
|
-
rate: exchangesData.exchanges[0]?.value
|
|
247
|
+
...item,
|
|
248
|
+
rate: exchangesData.exchanges[0]?.value,
|
|
249
249
|
}))));
|
|
250
250
|
return forkJoin($observables);
|
|
251
251
|
}));
|
|
252
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Fetches exchange data based on the provided query parameters.
|
|
255
|
+
*
|
|
256
|
+
* @param {QueryParams} params - The query parameters for retrieving exchange data.
|
|
257
|
+
* @return {Observable<CountryExchangesOut>} An observable containing the exchange data.
|
|
258
|
+
*/
|
|
259
|
+
getExchanges(params) {
|
|
260
|
+
return this.http.get(`${this.url}/exchanges`, {
|
|
261
|
+
params: httpParams(params),
|
|
262
|
+
}).pipe(map(({ data }) => data));
|
|
263
|
+
}
|
|
253
264
|
/**
|
|
254
265
|
* Retrieves the current exchanges based on the given query parameters.
|
|
255
266
|
*
|
|
256
267
|
* @param {QueryParams} params - The query parameters to filter the exchanges.
|
|
257
268
|
*
|
|
258
|
-
* @returns {Observable<
|
|
269
|
+
* @returns {Observable<ExchangesOut>} - An observable that emits the API response data containing the current exchanges.
|
|
259
270
|
*/
|
|
260
271
|
getCurrentExchanges(params) {
|
|
261
272
|
return this.http.get(`${this.url}/exchanges/current`, {
|
|
@@ -266,7 +277,7 @@ class ApiCompaniesService {
|
|
|
266
277
|
* Fetches the country-specific tax information for a company.
|
|
267
278
|
*
|
|
268
279
|
* @param {QueryParams} params - The parameters used to filter and query the taxes.
|
|
269
|
-
* @return {Observable<
|
|
280
|
+
* @return {Observable<CompanyCountryTaxesOut>} An observable that emits the tax information.
|
|
270
281
|
*/
|
|
271
282
|
getCompanyCountryTaxes(params) {
|
|
272
283
|
return this.http.get(`${this.url}/company-country-taxes`, {
|
|
@@ -277,7 +288,7 @@ class ApiCompaniesService {
|
|
|
277
288
|
* Retrieves the list of active account entities based on the provided query parameters.
|
|
278
289
|
*
|
|
279
290
|
* @param {QueryParams} params - The parameters to filter and query active account entities.
|
|
280
|
-
* @return {Observable<
|
|
291
|
+
* @return {Observable<AccountEntitiesOut>} An observable that emits the list of active account entities.
|
|
281
292
|
*/
|
|
282
293
|
getActiveAccountEntities(params) {
|
|
283
294
|
return this.http.get(`${this.url}/account-entities/actives`, {
|
|
@@ -289,7 +300,7 @@ class ApiCompaniesService {
|
|
|
289
300
|
*
|
|
290
301
|
* @param {Object} params - An object containing the required parameters.
|
|
291
302
|
* @param {string[]} params.paramNames - An array of parameter names for which the values need to be fetched.
|
|
292
|
-
* @return {Observable<
|
|
303
|
+
* @return {Observable<ParametersOut>} An observable that emits the fetched parameter values.
|
|
293
304
|
*/
|
|
294
305
|
getParameters({ paramNames, }) {
|
|
295
306
|
const parameters = paramNames.map((p) => ({ name: p }));
|
|
@@ -302,7 +313,7 @@ class ApiCompaniesService {
|
|
|
302
313
|
*
|
|
303
314
|
* @param {Object} input - The input object containing the parameter details.
|
|
304
315
|
* @param {string} input.paramName - The name of the parameter whose value is to be retrieved.
|
|
305
|
-
* @return {Observable<
|
|
316
|
+
* @return {Observable<ParameterValueOut>} An observable emitting the value of the specified parameter.
|
|
306
317
|
*/
|
|
307
318
|
getParameterValue({ paramName, }) {
|
|
308
319
|
return this.http.get(`${this.url}/parameters-values/${paramName}`)
|
|
@@ -312,7 +323,7 @@ class ApiCompaniesService {
|
|
|
312
323
|
* Retrieves a list of country references based on the given query parameters.
|
|
313
324
|
*
|
|
314
325
|
* @param {QueryParams} params - The query parameters for retrieving country references.
|
|
315
|
-
* @return {Observable<
|
|
326
|
+
* @return {Observable<CountryReferencesOut>} An observable containing the country reference data.
|
|
316
327
|
*/
|
|
317
328
|
getCountryReferences(params) {
|
|
318
329
|
return this.http.get(`${this.url}/country-references`, {
|
|
@@ -323,7 +334,7 @@ class ApiCompaniesService {
|
|
|
323
334
|
* Fetches the country reference data for a given country ID.
|
|
324
335
|
*
|
|
325
336
|
* @param {number} id - The unique identifier of the country for which the reference data is to be retrieved.
|
|
326
|
-
* @return {Observable<
|
|
337
|
+
* @return {Observable<CountryReferenceOut>} An observable containing the country reference data.
|
|
327
338
|
*/
|
|
328
339
|
getCountryReference(id) {
|
|
329
340
|
return this.http.get(`${this.url}/country-references/${id}`)
|
|
@@ -333,7 +344,7 @@ class ApiCompaniesService {
|
|
|
333
344
|
* Fetches the list of workflows based on the provided query parameters.
|
|
334
345
|
*
|
|
335
346
|
* @param {QueryParams} params - The query parameters used to filter workflows.
|
|
336
|
-
* @return {Observable<
|
|
347
|
+
* @return {Observable<WorkflowsOut>} An observable containing the workflow data.
|
|
337
348
|
*/
|
|
338
349
|
getWorkflows(params) {
|
|
339
350
|
return this.http.get(`${this.url}/workflows`, {
|
|
@@ -353,6 +364,115 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
|
353
364
|
args: ['env']
|
|
354
365
|
}] }, { type: i1.HttpClient }] });
|
|
355
366
|
|
|
367
|
+
class ApiInvoicesService {
|
|
368
|
+
environments;
|
|
369
|
+
http;
|
|
370
|
+
constructor(environments, http) {
|
|
371
|
+
this.environments = environments;
|
|
372
|
+
this.http = http;
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* Retrieves the API URL for invoices from the environments configuration.
|
|
376
|
+
*
|
|
377
|
+
* @return {string} The API URL for invoices.
|
|
378
|
+
*/
|
|
379
|
+
get url() {
|
|
380
|
+
return this.environments.apiInvoicesUrl;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Fetches and returns the collection receipt data for a given collection ID.
|
|
384
|
+
*
|
|
385
|
+
* @param {number} id - The unique identifier of the collection for which the receipt needs to be retrieved.
|
|
386
|
+
* @return {Observable<CollectionReceiptOut>} An observable containing the collection receipt data.
|
|
387
|
+
*/
|
|
388
|
+
printCollectionReceipt(id) {
|
|
389
|
+
return this.http.get(`${this.url}/operation/print/collection-receipt/${id}`)
|
|
390
|
+
.pipe(map(({ data }) => data));
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Handles the account payment operation by sending a POST request to the specified endpoint.
|
|
394
|
+
* Processes the response and returns the operation data.
|
|
395
|
+
*
|
|
396
|
+
* @param {AccountPaymentOperationIn} body The payload containing information for the account payment operation.
|
|
397
|
+
* @return {Observable<AccountPaymentOperationOut>} An observable emitting the processed account payment operation data.
|
|
398
|
+
*/
|
|
399
|
+
accountPaymentOperation(body) {
|
|
400
|
+
return this.http.post(`${this.url}/operation/account-payment`, body)
|
|
401
|
+
.pipe(map(({ data }) => data));
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Cancels a payment receipt based on the provided input.
|
|
405
|
+
* This method sends a POST request to cancel a document.
|
|
406
|
+
*
|
|
407
|
+
* @param body The data required to cancel the payment receipt, encapsulated in a CancelPaymentReceiptIn object.
|
|
408
|
+
* @return An Observable representing the result of the cancellation. Emits an empty object on success.
|
|
409
|
+
*/
|
|
410
|
+
cancelPaymentReceipt(body) {
|
|
411
|
+
return this.http.post(`${this.url}/operation/cancel-document`, body)
|
|
412
|
+
.pipe(map(({ data }) => data));
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Cancels an invoice based on the provided invoice ID and additional parameters.
|
|
416
|
+
*
|
|
417
|
+
* @param {Object} parameters - The parameters required to cancel the invoice, encapsulated in a CancelBillingIn object.
|
|
418
|
+
* @return {Observable<Object>} An observable that emits the response of the cancellation operation.
|
|
419
|
+
*/
|
|
420
|
+
cancelInvoice({ invoiceId, ...body }) {
|
|
421
|
+
return this.http.post(`${this.url}/operation/cancel-billing/${invoiceId}`, body)
|
|
422
|
+
.pipe(map(({ data }) => data));
|
|
423
|
+
}
|
|
424
|
+
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 });
|
|
425
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, providedIn: 'root' });
|
|
426
|
+
}
|
|
427
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiInvoicesService, decorators: [{
|
|
428
|
+
type: Injectable,
|
|
429
|
+
args: [{
|
|
430
|
+
providedIn: 'root'
|
|
431
|
+
}]
|
|
432
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
433
|
+
type: Inject,
|
|
434
|
+
args: ['env']
|
|
435
|
+
}] }, { type: i1.HttpClient }] });
|
|
436
|
+
|
|
437
|
+
class ApiReportsService {
|
|
438
|
+
environments;
|
|
439
|
+
http;
|
|
440
|
+
constructor(environments, http) {
|
|
441
|
+
this.environments = environments;
|
|
442
|
+
this.http = http;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Retrieves the URL for the reports API from the environment configurations.
|
|
446
|
+
*
|
|
447
|
+
* @return {string} The URL of the reports API.
|
|
448
|
+
*/
|
|
449
|
+
get url() {
|
|
450
|
+
return this.environments.apiReportsUrl;
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Retrieves the list of collection payments
|
|
454
|
+
*
|
|
455
|
+
* @param {QueryParams} params - The query parameters used to fetch the collection payments.
|
|
456
|
+
* @return {Observable<CollectionPaymentsOut[]>} An observable that emits an array of collection payment.
|
|
457
|
+
*/
|
|
458
|
+
getCollectionPayments(params) {
|
|
459
|
+
return this.http.get(`${this.url}/collection-payment`, {
|
|
460
|
+
params
|
|
461
|
+
}).pipe(map(({ data }) => data));
|
|
462
|
+
}
|
|
463
|
+
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 });
|
|
464
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, providedIn: 'root' });
|
|
465
|
+
}
|
|
466
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiReportsService, decorators: [{
|
|
467
|
+
type: Injectable,
|
|
468
|
+
args: [{
|
|
469
|
+
providedIn: 'root'
|
|
470
|
+
}]
|
|
471
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
472
|
+
type: Inject,
|
|
473
|
+
args: ['env']
|
|
474
|
+
}] }, { type: i1.HttpClient }] });
|
|
475
|
+
|
|
356
476
|
class ApiSecurityService {
|
|
357
477
|
environments;
|
|
358
478
|
cookie;
|
|
@@ -410,8 +530,9 @@ class ApiSecurityService {
|
|
|
410
530
|
*/
|
|
411
531
|
createSession({ modelType, modelId, token, }) {
|
|
412
532
|
let headers = new HttpHeaders({});
|
|
413
|
-
if (token)
|
|
533
|
+
if (token) {
|
|
414
534
|
headers = headers.set('Authorization', `Bearer ${token}`);
|
|
535
|
+
}
|
|
415
536
|
return this.http.post(`${this.url}/sessions`, {
|
|
416
537
|
model_type: modelType,
|
|
417
538
|
model_id: modelId,
|
|
@@ -465,6 +586,69 @@ class ApiSecurityService {
|
|
|
465
586
|
language_id: languageId
|
|
466
587
|
}).pipe(map(({ data }) => data));
|
|
467
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Retrieves the role types from the API.
|
|
591
|
+
*
|
|
592
|
+
* @param {QueryParams} params - The query parameters to be sent with the request.
|
|
593
|
+
* @returns {Observable<RoleTypesOut>} An observable containing the role types output.
|
|
594
|
+
*/
|
|
595
|
+
getRoleTypes(params) {
|
|
596
|
+
return this.http.get(`${this.url}/role-types`, {
|
|
597
|
+
params
|
|
598
|
+
}).pipe(map(({ data }) => data));
|
|
599
|
+
}
|
|
600
|
+
/**
|
|
601
|
+
* Retrieves the permissions for a module.
|
|
602
|
+
*
|
|
603
|
+
* @param {QueryParams} params - The query parameters to be sent with the request.
|
|
604
|
+
* @returns {Observable<ModulePermissionsOut>} An observable containing the module permissions.
|
|
605
|
+
*/
|
|
606
|
+
getPermissions(params) {
|
|
607
|
+
return this.http.get(`${this.url}/modules`, {
|
|
608
|
+
params
|
|
609
|
+
}).pipe(map(({ data }) => data));
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Retrieves roles by the specified ID.
|
|
613
|
+
*
|
|
614
|
+
* @param params - The ID of the role to retrieve.
|
|
615
|
+
* @returns An Observable that emits the role data.
|
|
616
|
+
*/
|
|
617
|
+
getRolesById(params) {
|
|
618
|
+
return this.http.get(`${this.url}/roles/${params}`)
|
|
619
|
+
.pipe(map(({ data }) => data));
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Creates a new role with the specified permissions.
|
|
623
|
+
*
|
|
624
|
+
* @param {RolePermissionsIn} body - The permissions and details for the new role.
|
|
625
|
+
* @returns {Observable<ModulePermissionsOut>} An observable containing the created role's permissions.
|
|
626
|
+
*/
|
|
627
|
+
createRole(body) {
|
|
628
|
+
return this.http.post(`${this.url}/roles`, body)
|
|
629
|
+
.pipe(map(({ data }) => data));
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Updates the permissions of a specific role.
|
|
633
|
+
*
|
|
634
|
+
* @param id - The unique identifier of the role to update.
|
|
635
|
+
* @param body - The new permissions to assign to the role.
|
|
636
|
+
* @returns An Observable that emits the updated module permissions.
|
|
637
|
+
*/
|
|
638
|
+
updateRolePermissions(id, body) {
|
|
639
|
+
return this.http.put(`${this.url}/roles/${id}`, body)
|
|
640
|
+
.pipe(map(({ data }) => data));
|
|
641
|
+
}
|
|
642
|
+
/**
|
|
643
|
+
* Deletes the permissions associated with a specific role.
|
|
644
|
+
*
|
|
645
|
+
* @param {number} id - The unique identifier of the role whose permissions are to be deleted.
|
|
646
|
+
* @returns {Observable<{}>} An observable that emits the result of the delete operation.
|
|
647
|
+
*/
|
|
648
|
+
deleteRolePermissions(id) {
|
|
649
|
+
return this.http.delete(`${this.url}/roles/${id}`)
|
|
650
|
+
.pipe(map(({ data }) => data));
|
|
651
|
+
}
|
|
468
652
|
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 });
|
|
469
653
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiSecurityService, providedIn: 'root' });
|
|
470
654
|
}
|
|
@@ -478,6 +662,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
|
478
662
|
args: ['env']
|
|
479
663
|
}] }, { type: i1$1.CookieService }, { type: i1.HttpClient }] });
|
|
480
664
|
|
|
665
|
+
class ApiShipmentsService {
|
|
666
|
+
environments;
|
|
667
|
+
http;
|
|
668
|
+
constructor(environments, http) {
|
|
669
|
+
this.environments = environments;
|
|
670
|
+
this.http = http;
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Retrieves the URL for the shipments API from the environment configurations.
|
|
674
|
+
*
|
|
675
|
+
* @return {string} The URL of the shipments API.
|
|
676
|
+
*/
|
|
677
|
+
get url() {
|
|
678
|
+
return this.environments.apiShipmentUrl;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Retrieves the parameter values based on the provided parameter names.
|
|
682
|
+
*
|
|
683
|
+
* @param {ValidateAccountIn} body - An object of parameter names for which the values need to be fetched.
|
|
684
|
+
* @return {Observable<ValidateAccountIn>} An observable that emits the fetched parameter values
|
|
685
|
+
* @param body
|
|
686
|
+
*/
|
|
687
|
+
validateAccount(body) {
|
|
688
|
+
return this.http.post(`${this.url}/accounts`, body)
|
|
689
|
+
.pipe(map(({ data }) => data));
|
|
690
|
+
}
|
|
691
|
+
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 });
|
|
692
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, providedIn: 'root' });
|
|
693
|
+
}
|
|
694
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: ApiShipmentsService, decorators: [{
|
|
695
|
+
type: Injectable,
|
|
696
|
+
args: [{
|
|
697
|
+
providedIn: 'root'
|
|
698
|
+
}]
|
|
699
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
700
|
+
type: Inject,
|
|
701
|
+
args: ['env']
|
|
702
|
+
}] }, { type: i1.HttpClient }] });
|
|
703
|
+
|
|
481
704
|
class CryptoService {
|
|
482
705
|
environments;
|
|
483
706
|
constructor(environments) {
|
|
@@ -500,15 +723,16 @@ class CryptoService {
|
|
|
500
723
|
async decryptAES(payload) {
|
|
501
724
|
// Extract the Initialization Vector (IV), and the cypher text
|
|
502
725
|
const [base64IV, base64Ciphertext] = payload.split(':');
|
|
503
|
-
if (!base64IV || !base64Ciphertext)
|
|
726
|
+
if (!base64IV || !base64Ciphertext) {
|
|
504
727
|
throw new Error('The payload must contain the IV and the cipher text.');
|
|
728
|
+
}
|
|
505
729
|
const cryptoKey = await this.loadKey();
|
|
506
730
|
const iv = this.base64ToUint8Array(base64IV);
|
|
507
731
|
const cipherText = this.base64ToArrayBuffer(base64Ciphertext);
|
|
508
732
|
// Decrypt the cypher text
|
|
509
733
|
const decrypted = await crypto.subtle.decrypt({
|
|
510
734
|
name: 'AES-GCM',
|
|
511
|
-
iv
|
|
735
|
+
iv,
|
|
512
736
|
}, cryptoKey, cipherText);
|
|
513
737
|
// Decode the decrypted text
|
|
514
738
|
const decoder = new TextDecoder();
|
|
@@ -570,25 +794,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
|
570
794
|
|
|
571
795
|
class ApiHeadersInterceptor {
|
|
572
796
|
/**
|
|
573
|
-
* Intercepts HTTP requests and
|
|
574
|
-
*
|
|
575
|
-
* @param {HttpRequest<unknown>} request - The HTTP request intercepted.
|
|
576
|
-
* @param {HttpHandler} next - The next handler in the chain.
|
|
797
|
+
* Intercepts HTTP requests and modifies request headers to include caching, content type,
|
|
798
|
+
* accept language, and other HTTP-specific configurations before forwarding the request onward.
|
|
577
799
|
*
|
|
578
|
-
* @
|
|
800
|
+
* @param {HttpRequest<unknown>} request - The HTTP request instance to be intercepted and modified.
|
|
801
|
+
* @param {HttpHandler} next - The next handler instance in the HTTP pipeline which processes
|
|
802
|
+
* the modified request and forwards it.
|
|
803
|
+
* @return {Observable<HttpEvent<unknown>>} An observable of the processed HTTP event.
|
|
579
804
|
*/
|
|
580
805
|
intercept(request, next) {
|
|
581
806
|
let headers = new HttpHeaders({
|
|
582
807
|
'cache-control': 'max-age=0, no-cache, no-store, must-revalidate',
|
|
583
|
-
|
|
584
|
-
|
|
808
|
+
expires: '0',
|
|
809
|
+
pragma: 'no-cache'
|
|
585
810
|
});
|
|
586
|
-
if (!request.headers.has('Content-Type'))
|
|
811
|
+
if (!request.headers.has('Content-Type')) {
|
|
587
812
|
headers = headers.set('Content-Type', 'application/json');
|
|
588
|
-
|
|
813
|
+
}
|
|
814
|
+
if (!request.headers.has('Accept')) {
|
|
589
815
|
headers = headers.set('Accept', 'application/json');
|
|
590
|
-
|
|
816
|
+
}
|
|
817
|
+
if (!request.headers.has('Accept-Language')) {
|
|
591
818
|
headers = headers.set('Accept-Language', localStorage.getItem('lang') ?? 'en');
|
|
819
|
+
}
|
|
592
820
|
request = request.clone({ headers });
|
|
593
821
|
return next.handle(request);
|
|
594
822
|
}
|
|
@@ -607,16 +835,17 @@ class ApiTokenInterceptor {
|
|
|
607
835
|
this.cookie = cookie;
|
|
608
836
|
}
|
|
609
837
|
/**
|
|
610
|
-
* Intercepts the HTTP request
|
|
611
|
-
*
|
|
612
|
-
* @param {HttpRequest<unknown>} request - The HTTP request to intercept.
|
|
613
|
-
* @param {HttpHandler} next - The next HTTP handler in the chain.
|
|
838
|
+
* Intercepts and modifies the outgoing HTTP request to include an authorization token
|
|
839
|
+
* from cookies if the request does not already have an Authorization or AppKey header.
|
|
614
840
|
*
|
|
615
|
-
* @
|
|
841
|
+
* @param {HttpRequest<unknown>} request - The outgoing HTTP request to be intercepted.
|
|
842
|
+
* @param {HttpHandler} next - The next handler in the HTTP request processing chain.
|
|
843
|
+
* @return {Observable<HttpEvent<unknown>>} An observable of the HTTP event, modified or unmodified.
|
|
616
844
|
*/
|
|
617
845
|
intercept(request, next) {
|
|
618
|
-
if (request.headers.has('Authorization'))
|
|
846
|
+
if (request.headers.has('Authorization') || request.headers.has('AppKey')) {
|
|
619
847
|
return next.handle(request);
|
|
848
|
+
}
|
|
620
849
|
const token = this.cookie.get(this.environments.authCookie);
|
|
621
850
|
if (!token)
|
|
622
851
|
return next.handle(request);
|
|
@@ -644,19 +873,30 @@ class HttpCachingInterceptor {
|
|
|
644
873
|
constructor(envs) {
|
|
645
874
|
this.envs = envs;
|
|
646
875
|
}
|
|
876
|
+
/**
|
|
877
|
+
* Intercepts HTTP requests to add caching functionality for GET requests.
|
|
878
|
+
* Non-GET requests are passed through without caching.
|
|
879
|
+
*
|
|
880
|
+
* @param {HttpRequest<any>} req - The HTTP request being intercepted.
|
|
881
|
+
* @param {HttpHandler} next - The next handler in the HTTP pipeline to execute the request.
|
|
882
|
+
* @return {Observable<HttpEvent<any>>} - An observable containing the HTTP response event, either from cache or the backend service.
|
|
883
|
+
*/
|
|
647
884
|
intercept(req, next) {
|
|
648
|
-
if (req.method !== 'GET')
|
|
885
|
+
if (req.method !== 'GET') {
|
|
649
886
|
return next.handle(req);
|
|
887
|
+
}
|
|
650
888
|
const cached = this.cache.get(req.urlWithParams);
|
|
651
889
|
if (cached) {
|
|
652
890
|
const isExpired = Date.now() > cached.ttl;
|
|
653
|
-
if (!isExpired)
|
|
891
|
+
if (!isExpired) {
|
|
654
892
|
return of(cached.res);
|
|
893
|
+
}
|
|
655
894
|
this.cache.delete(req.urlWithParams); // If expired, remove the entry from cache
|
|
656
895
|
}
|
|
657
896
|
return next.handle(req).pipe(tap$1((res) => {
|
|
658
|
-
if (!(res instanceof HttpResponse))
|
|
897
|
+
if (!(res instanceof HttpResponse)) {
|
|
659
898
|
return;
|
|
899
|
+
}
|
|
660
900
|
const ttl = Date.now() + (this.envs.cacheTtl ?? DEFAULT_TTL);
|
|
661
901
|
this.cache.set(req.urlWithParams, { res, ttl });
|
|
662
902
|
}));
|
|
@@ -679,5 +919,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImpo
|
|
|
679
919
|
* Generated bundle index. Do not edit.
|
|
680
920
|
*/
|
|
681
921
|
|
|
682
|
-
export { ApiCompaniesService, ApiHeadersInterceptor, ApiSecurityService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, httpParams, pdfHeaders, queryString, xmlHeaders };
|
|
922
|
+
export { ApiCompaniesService, ApiHeadersInterceptor, ApiInvoicesService, ApiReportsService, ApiSecurityService, ApiShipmentsService, ApiTokenInterceptor, CryptoService, HttpCachingInterceptor, NgxServicesModule, httpParams, pdfHeaders, queryString, xmlHeaders };
|
|
683
923
|
//# sourceMappingURL=experteam-mx-ngx-services.mjs.map
|