@experteam-mx/ngx-services 20.0.0-beta.1 → 20.0.0-beta.2

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.
@@ -1502,7 +1502,7 @@ class ApiCompaniesService {
1502
1502
  * @return {Observable<AccountsOut>} An observable emitting the account data.
1503
1503
  */
1504
1504
  getAccounts(params) {
1505
- return this.http.get(`${this.url}/accounts`)
1505
+ return this.http.get(`${this.url}/accounts`, { params })
1506
1506
  .pipe(map(({ data }) => data));
1507
1507
  }
1508
1508
  /**
@@ -2527,55 +2527,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
2527
2527
  args: ['env']
2528
2528
  }] }, { type: i1.HttpClient }] });
2529
2529
 
2530
- class ApiEventsService {
2531
- environments;
2532
- http;
2533
- constructor(environments, http) {
2534
- this.environments = environments;
2535
- this.http = http;
2536
- }
2537
- /**
2538
- * Gets the API endpoint URL for Events from the environments configuration.
2539
- *
2540
- * @return {string} The URL for the Events API. Returns an empty string if not defined.
2541
- */
2542
- get url() {
2543
- return this.environments.apiEventsUrl ?? '';
2544
- }
2545
- /**
2546
- * Sends a request to start an event
2547
- *
2548
- * @param {OperationModuleStartIn} body - The event information to be submitted.
2549
- * @return {Observable<OperationModuleOut>} An Observable emitting the server's response containing the created event details.
2550
- */
2551
- postOperationModulesStart(body) {
2552
- return this.http.post(`${this.url}/operation-modules/start`, body)
2553
- .pipe(map(({ data }) => data));
2554
- }
2555
- /**
2556
- * Updates the discount information for a specific item.
2557
- *
2558
- * @param {number} id - The unique identifier of the item whose event is to be updated.
2559
- * @param {OperationModuleEndIn} body - The payload containing the updated event details.
2560
- * @return {Observable<OperationModuleOut>} An observable emitting the updated event details.
2561
- */
2562
- putOperationModulesEnd(id, body) {
2563
- return this.http.put(`${this.url}/operation-modules/${id}/end`, body)
2564
- .pipe(map(({ data }) => data));
2565
- }
2566
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
2567
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, providedIn: 'root' });
2568
- }
2569
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, decorators: [{
2570
- type: Injectable,
2571
- args: [{
2572
- providedIn: 'root'
2573
- }]
2574
- }], ctorParameters: () => [{ type: undefined, decorators: [{
2575
- type: Inject,
2576
- args: ['env']
2577
- }] }, { type: i1.HttpClient }] });
2578
-
2579
2530
  class ApiEToolsAutoBillingService {
2580
2531
  environments;
2581
2532
  http;
@@ -2647,12 +2598,61 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
2647
2598
  args: ['env']
2648
2599
  }] }, { type: i1.HttpClient }] });
2649
2600
 
2650
- class ApiExternalPickupsService {
2651
- httpClient;
2601
+ class ApiEventsService {
2602
+ environments;
2603
+ http;
2604
+ constructor(environments, http) {
2605
+ this.environments = environments;
2606
+ this.http = http;
2607
+ }
2608
+ /**
2609
+ * Gets the API endpoint URL for Events from the environments configuration.
2610
+ *
2611
+ * @return {string} The URL for the Events API. Returns an empty string if not defined.
2612
+ */
2613
+ get url() {
2614
+ return this.environments.apiEventsUrl ?? '';
2615
+ }
2616
+ /**
2617
+ * Sends a request to start an event
2618
+ *
2619
+ * @param {OperationModuleStartIn} body - The event information to be submitted.
2620
+ * @return {Observable<OperationModuleOut>} An Observable emitting the server's response containing the created event details.
2621
+ */
2622
+ postOperationModulesStart(body) {
2623
+ return this.http.post(`${this.url}/operation-modules/start`, body)
2624
+ .pipe(map(({ data }) => data));
2625
+ }
2626
+ /**
2627
+ * Updates the discount information for a specific item.
2628
+ *
2629
+ * @param {number} id - The unique identifier of the item whose event is to be updated.
2630
+ * @param {OperationModuleEndIn} body - The payload containing the updated event details.
2631
+ * @return {Observable<OperationModuleOut>} An observable emitting the updated event details.
2632
+ */
2633
+ putOperationModulesEnd(id, body) {
2634
+ return this.http.put(`${this.url}/operation-modules/${id}/end`, body)
2635
+ .pipe(map(({ data }) => data));
2636
+ }
2637
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, deps: [{ token: 'env' }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
2638
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, providedIn: 'root' });
2639
+ }
2640
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiEventsService, decorators: [{
2641
+ type: Injectable,
2642
+ args: [{
2643
+ providedIn: 'root'
2644
+ }]
2645
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2646
+ type: Inject,
2647
+ args: ['env']
2648
+ }] }, { type: i1.HttpClient }] });
2649
+
2650
+ class ApiExternalOperationsService {
2651
+ http;
2652
2652
  environment;
2653
2653
  appKey;
2654
- constructor(httpClient, environment) {
2655
- this.httpClient = httpClient;
2654
+ constructor(http, environment) {
2655
+ this.http = http;
2656
2656
  this.environment = environment;
2657
2657
  this.appKey = environment.apiExternalOperationsKey ?? '';
2658
2658
  }
@@ -2666,6 +2666,16 @@ class ApiExternalPickupsService {
2666
2666
  get url() {
2667
2667
  return this.environment.apiExternalOperationsUrl ?? '';
2668
2668
  }
2669
+ /**
2670
+ * Retrieves delivery confirmation details based on the provided OTP code.
2671
+ *
2672
+ * @param {string} otpCode - The OTP code used to search for delivery confirmation.
2673
+ * @return {Observable<DeliveryConfirmationData>} An observable containing the delivery confirmation data.
2674
+ */
2675
+ getDeliveryConfirmation(otpCode) {
2676
+ return this.http.get(`${this.url}/delivery-confirmation/search/${otpCode}`)
2677
+ .pipe(map$1(({ data }) => data));
2678
+ }
2669
2679
  /**
2670
2680
  * Generates a delivery confirmation by sending the provided payload to the API.
2671
2681
  *
@@ -2673,8 +2683,8 @@ class ApiExternalPickupsService {
2673
2683
  * @return {Observable<DeliveryConfirmationGenerateOut>} An observable that emits the generated delivery confirmation data.
2674
2684
  */
2675
2685
  postDeliveryConfirmationGenerate(payload) {
2676
- return this.httpClient.post(`${this.url}/delivery-confirmation/generate`, payload, {
2677
- headers: { appkey: this.appKey }
2686
+ return this.http.post(`${this.url}/delivery-confirmation/generate`, payload, {
2687
+ headers: this.getAppKeyHeader(),
2678
2688
  }).pipe(map$1(({ data }) => data));
2679
2689
  }
2680
2690
  /**
@@ -2686,8 +2696,8 @@ class ApiExternalPickupsService {
2686
2696
  * @return {Observable<Object>} - An observable containing the response data from the API.
2687
2697
  */
2688
2698
  patchDeliveryConfirmationComplete({ keyOTP, operationId, }) {
2689
- return this.httpClient.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
2690
- headers: { appkey: this.appKey },
2699
+ return this.http.patch(`${this.url}/delivery-confirmation/completed/${keyOTP}`, null, {
2700
+ headers: this.getAppKeyHeader(),
2691
2701
  params: { operation_id: operationId }
2692
2702
  }).pipe(map$1(({ data }) => data));
2693
2703
  }
@@ -2700,14 +2710,17 @@ class ApiExternalPickupsService {
2700
2710
  * @return {Observable<Object>} An observable that emits the server's response when the cancellation is processed.
2701
2711
  */
2702
2712
  putDeliveryConfirmation({ otp, ...body }) {
2703
- return this.httpClient.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
2704
- headers: { appkey: this.appKey },
2713
+ return this.http.put(`${this.url}/delivery-confirmation/confirmation/${otp}`, body, {
2714
+ headers: this.getAppKeyHeader(),
2705
2715
  }).pipe(map$1(({ data }) => data));
2706
2716
  }
2707
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalPickupsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
2708
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalPickupsService, providedIn: 'root' });
2717
+ getAppKeyHeader() {
2718
+ return { ...(this.appKey && { AppKey: this.appKey }) };
2719
+ }
2720
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalOperationsService, deps: [{ token: i1.HttpClient }, { token: 'env' }], target: i0.ɵɵFactoryTarget.Injectable });
2721
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalOperationsService, providedIn: 'root' });
2709
2722
  }
2710
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalPickupsService, decorators: [{
2723
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: ApiExternalOperationsService, decorators: [{
2711
2724
  type: Injectable,
2712
2725
  args: [{
2713
2726
  providedIn: 'root'
@@ -4397,6 +4410,52 @@ function apiHeadersInterceptor(req, next) {
4397
4410
  return next(req);
4398
4411
  }
4399
4412
 
4413
+ /**
4414
+ * HTTP interceptor that injects the external operations API key into outbound requests.
4415
+ *
4416
+ * The interceptor:
4417
+ * 1. Reads `apiExternalOperationsKey` from the injected `ENVIRONMENT_TOKEN`.
4418
+ * 2. Skips modification if the key is absent.
4419
+ * 3. Leaves the request unchanged if it already contains an `AppKey` header (caller override).
4420
+ * 4. Otherwise clones the request adding `AppKey: apiExternalOperationsKey`.
4421
+ *
4422
+ * This enables centralized, transparent authentication for services targeting external
4423
+ * operations endpoints while allowing explicit per-request overrides.
4424
+ *
4425
+ * Example:
4426
+ * ```ts
4427
+ * provideHttpClient(
4428
+ * withInterceptors([apiKeyInterceptor])
4429
+ * );
4430
+ * ```
4431
+ *
4432
+ * @param request The original immutable `HttpRequest` instance.
4433
+ * @param next The next handler in the interceptor chain, used to forward the (possibly cloned) request.
4434
+ * @returns An `Observable` stream of the HTTP events for the (potentially augmented) request.
4435
+ *
4436
+ * @remarks
4437
+ * - If you need to intentionally send a different key for a specific request, set the `AppKey`
4438
+ * header manually before this interceptor runs.
4439
+ * - If `apiExternalOperationsKey` is undefined (e.g., missing configuration), the request is passed through unchanged.
4440
+ * - Order matters: place this interceptor before others that rely on the presence of the `AppKey` header.
4441
+ *
4442
+ * @see HttpRequest
4443
+ * @see HttpHandlerFn
4444
+ */
4445
+ function apiKeyInterceptor(request, next) {
4446
+ const { apiExternalOperationsKey } = inject(ENVIRONMENT_TOKEN);
4447
+ if (!apiExternalOperationsKey)
4448
+ return next(request);
4449
+ if (request.headers.has('AppKey'))
4450
+ return next(request);
4451
+ request = request.clone({
4452
+ setHeaders: {
4453
+ AppKey: apiExternalOperationsKey
4454
+ }
4455
+ });
4456
+ return next(request);
4457
+ }
4458
+
4400
4459
  /**
4401
4460
  * An HTTP interceptor to append an Authorization header with a Bearer token
4402
4461
  * to outgoing HTTP requests if certain conditions are met.
@@ -4454,6 +4513,15 @@ function httpCachingInterceptor(req, next) {
4454
4513
  }));
4455
4514
  }
4456
4515
 
4516
+ const base64PdfToUrl = (base64) => {
4517
+ const data = new Uint8Array(atob(base64)
4518
+ .split('')
4519
+ .map(char => char.charCodeAt(0)));
4520
+ const blob = new Blob([data], { type: 'application/pdf' });
4521
+ return window.URL.createObjectURL(blob);
4522
+ };
4523
+ const downloadBase64Pdf = (base64) => window.open(base64PdfToUrl(base64));
4524
+
4457
4525
  /**
4458
4526
  * Convert an object of key-value pairs into a URL query string.
4459
4527
  *
@@ -4519,15 +4587,6 @@ const xmlHeaders = (format = 'object') => {
4519
4587
  : new HttpHeaders(headers);
4520
4588
  };
4521
4589
 
4522
- const base64PdfToUrl = (base64) => {
4523
- const data = new Uint8Array(atob(base64)
4524
- .split('')
4525
- .map(char => char.charCodeAt(0)));
4526
- const blob = new Blob([data], { type: 'application/pdf' });
4527
- return window.URL.createObjectURL(blob);
4528
- };
4529
- const downloadBase64Pdf = (base64) => window.open(base64PdfToUrl(base64));
4530
-
4531
4590
  /*
4532
4591
  * Public API Surface of ngx-services
4533
4592
  */
@@ -4536,5 +4595,5 @@ const downloadBase64Pdf = (base64) => window.open(base64PdfToUrl(base64));
4536
4595
  * Generated bundle index. Do not edit.
4537
4596
  */
4538
4597
 
4539
- export { AlphaNumeric, ApiBillingDOService, ApiBillingGtService, ApiBillingMxService, ApiBillingPaService, ApiBillingSvService, ApiCashOperationsService, ApiCatalogsService, ApiCompaniesService, ApiCompositionService, ApiCustomsService, ApiDiscountsService, ApiEToolsAutoBillingService, ApiEventsService, ApiExternalPickupsService, ApiInventoriesService, ApiInvoicesService, ApiNotificationsService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiServicesService, ApiShipmentsService, ApiSuppliesService, CryptoService, DefaultValueType, ENVIRONMENT_TOKEN, Event, NgxServicesModule, OperationModuleStatus, ViewSectionOption, WebSocketsService, apiHeadersInterceptor, apiTokenInterceptor, base64PdfToUrl, downloadBase64Pdf, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
4598
+ export { AlphaNumeric, ApiBillingDOService, ApiBillingGtService, ApiBillingMxService, ApiBillingPaService, ApiBillingSvService, ApiCashOperationsService, ApiCatalogsService, ApiCompaniesService, ApiCompositionService, ApiCustomsService, ApiDiscountsService, ApiEToolsAutoBillingService, ApiEventsService, ApiExternalOperationsService, ApiInventoriesService, ApiInvoicesService, ApiNotificationsService, ApiOpenItemsService, ApiReportsService, ApiSecurityService, ApiServicesService, ApiShipmentsService, ApiSuppliesService, CryptoService, DefaultValueType, ENVIRONMENT_TOKEN, Event, NgxServicesModule, OperationModuleStatus, ViewSectionOption, WebSocketsService, apiHeadersInterceptor, apiKeyInterceptor, apiTokenInterceptor, base64PdfToUrl, downloadBase64Pdf, httpCachingInterceptor, httpParams, pdfHeaders, queryString, xmlHeaders };
4540
4599
  //# sourceMappingURL=experteam-mx-ngx-services.mjs.map