@praxisui/core 8.0.0-beta.72 → 8.0.0-beta.74

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.
@@ -4304,7 +4304,7 @@ class GenericCrudService {
4304
4304
  // Absolute HTTP/HTTPS URL
4305
4305
  let url = customUserEndpoint.replace(/\/+$/, '');
4306
4306
  if ((operation === 'getById' || operation === 'update' || operation === 'delete') && id !== undefined && id !== null) {
4307
- url += `/${id}`;
4307
+ url = this.resolveEntityEndpointTemplate(url, id);
4308
4308
  }
4309
4309
  return url;
4310
4310
  }
@@ -4314,7 +4314,7 @@ class GenericCrudService {
4314
4314
  let url = `${baseApiUrl}/${endpoint}`;
4315
4315
  url = url.replace(/\/+$/, '');
4316
4316
  if ((operation === 'getById' || operation === 'update' || operation === 'delete') && id !== undefined && id !== null) {
4317
- url += `/${id}`;
4317
+ url = this.resolveEntityEndpointTemplate(url, id);
4318
4318
  }
4319
4319
  return url;
4320
4320
  }
@@ -4364,6 +4364,13 @@ class GenericCrudService {
4364
4364
  throw new Error(`Unknown operation: ${operation}`);
4365
4365
  }
4366
4366
  }
4367
+ resolveEntityEndpointTemplate(url, id) {
4368
+ const encodedId = encodeURIComponent(String(id));
4369
+ if (url.includes('{id}') || /:id\b/.test(url)) {
4370
+ return url.replace(/\{id\}/g, encodedId).replace(/:id\b/g, encodedId);
4371
+ }
4372
+ return `${url}/${encodedId}`;
4373
+ }
4367
4374
  getResourceBaseUrl(options) {
4368
4375
  const url = this.getEndpointUrl('filter', undefined, options?.parentPath, options?.endpointKey);
4369
4376
  return url.replace(/\/filter$/, '');
@@ -11906,6 +11913,13 @@ class ResourceSurfaceOpenAdapterService {
11906
11913
  apiEndpointKey: options.endpointKey ?? null,
11907
11914
  apiUrlEntry: options.apiUrlEntry ?? (discoveryOptions ? this.discovery.resolveApiEntry(discoveryOptions) : null),
11908
11915
  };
11916
+ if (surface.scope === 'ITEM' && this.isReadableFormSurface(surface.kind)) {
11917
+ payload.widget.inputs['customEndpoints'] = {
11918
+ ...(payload.widget.inputs['customEndpoints'] || {}),
11919
+ getById: this.discovery.resolveHref(surface.path, discoveryOptions),
11920
+ };
11921
+ payload.widget.bindingOrder = this.withInputBefore(payload.widget.bindingOrder, 'customEndpoints', 'resourceId');
11922
+ }
11909
11923
  if (this.isWritableFormSurface(surface.kind)) {
11910
11924
  payload.widget.inputs['submitMethod'] = surface.method.toLowerCase();
11911
11925
  payload.widget.inputs['submitUrl'] = resolvedSubmitUrl;
@@ -11939,6 +11953,15 @@ class ResourceSurfaceOpenAdapterService {
11939
11953
  buildStableInstanceId(surface) {
11940
11954
  return `${surface.resourceKey}.${surface.id}`.replace(/[^a-zA-Z0-9._-]+/g, '-');
11941
11955
  }
11956
+ withInputBefore(bindingOrder, input, beforeInput) {
11957
+ const next = (bindingOrder || []).filter((item) => item !== input);
11958
+ const targetIndex = next.indexOf(beforeInput);
11959
+ if (targetIndex >= 0) {
11960
+ next.splice(targetIndex, 0, input);
11961
+ return next;
11962
+ }
11963
+ return [...next, input];
11964
+ }
11942
11965
  normalizeResourcePath(resourcePath) {
11943
11966
  return String(resourcePath || '').trim().replace(/^\/+/, '').replace(/\/+$/, '');
11944
11967
  }
@@ -11957,6 +11980,9 @@ class ResourceSurfaceOpenAdapterService {
11957
11980
  isWritableFormSurface(kind) {
11958
11981
  return kind === 'FORM' || kind === 'PARTIAL_FORM';
11959
11982
  }
11983
+ isReadableFormSurface(kind) {
11984
+ return kind === 'VIEW' || kind === 'READ_PROJECTION';
11985
+ }
11960
11986
  buildIdBinding(idBindingPath) {
11961
11987
  return {
11962
11988
  from: idBindingPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@praxisui/core",
3
- "version": "8.0.0-beta.72",
3
+ "version": "8.0.0-beta.74",
4
4
  "description": "Core library for Praxis UI Workspace: types, tokens, services and utilities shared across @praxisui/* packages.",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^21.0.0",
@@ -5048,6 +5048,7 @@ declare class GenericCrudService<T, ID extends string | number = string | number
5048
5048
  * @throws Error quando o ID é obrigatório mas não fornecido, ou quando o serviço não está configurado
5049
5049
  */
5050
5050
  private getEndpointUrl;
5051
+ private resolveEntityEndpointTemplate;
5051
5052
  private getResourceBaseUrl;
5052
5053
  /**
5053
5054
  * Resolve `/schemas/filtered` base URL honoring ApiUrlConfig (supports APIs on another origin).
@@ -8950,10 +8951,12 @@ declare class ResourceSurfaceOpenAdapterService {
8950
8951
  toPayload(surface: ResourceSurfaceCatalogItem, options: ResourceSurfaceOpenAdapterOptions): SurfaceOpenPayload;
8951
8952
  private buildBasePayload;
8952
8953
  private buildStableInstanceId;
8954
+ private withInputBefore;
8953
8955
  private normalizeResourcePath;
8954
8956
  private resolveFormMode;
8955
8957
  private isCollectionView;
8956
8958
  private isWritableFormSurface;
8959
+ private isReadableFormSurface;
8957
8960
  private buildIdBinding;
8958
8961
  private clone;
8959
8962
  static ɵfac: i0.ɵɵFactoryDeclaration<ResourceSurfaceOpenAdapterService, never>;