@acorex/platform 20.6.3 → 20.6.4
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/auth/index.d.ts +228 -3
- package/fesm2022/acorex-platform-auth.mjs +162 -2
- package/fesm2022/acorex-platform-auth.mjs.map +1 -1
- package/fesm2022/acorex-platform-layout-entity.mjs +50 -18
- package/fesm2022/acorex-platform-layout-entity.mjs.map +1 -1
- package/layout/entity/index.d.ts +7 -0
- package/package.json +1 -1
|
@@ -599,7 +599,30 @@ class AXPEntityFormBuilderService {
|
|
|
599
599
|
//#endregion
|
|
600
600
|
//#region ---- Public API ----
|
|
601
601
|
entity(fullName) {
|
|
602
|
-
return new InterfaceSelector(this.entityRegistry, this.layoutBuilder, this.deviceService, fullName);
|
|
602
|
+
return new InterfaceSelector(this.entityRegistry, this.layoutBuilder, this.deviceService, fullName, this);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Fetches a record by ID for the specified entity.
|
|
606
|
+
* @param fullName - Entity full name in "module.entity" format
|
|
607
|
+
* @param id - Record ID to fetch
|
|
608
|
+
* @returns Promise resolving to the record data, or empty object if not found
|
|
609
|
+
*/
|
|
610
|
+
async getRecordById(fullName, id) {
|
|
611
|
+
if (!id) {
|
|
612
|
+
throw new Error('Record id is required.');
|
|
613
|
+
}
|
|
614
|
+
const { moduleName, entityName } = parseEntityFullName(fullName);
|
|
615
|
+
const entity = await this.entityRegistry.resolve(moduleName, entityName);
|
|
616
|
+
try {
|
|
617
|
+
const byKeyFn = entity?.queries?.byKey?.execute;
|
|
618
|
+
if (typeof byKeyFn === 'function') {
|
|
619
|
+
return (await byKeyFn(id)) ?? {};
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
// Return empty object if fetch fails
|
|
624
|
+
}
|
|
625
|
+
return {};
|
|
603
626
|
}
|
|
604
627
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityFormBuilderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
605
628
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: AXPEntityFormBuilderService, providedIn: 'root' }); }
|
|
@@ -610,14 +633,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
610
633
|
}] });
|
|
611
634
|
//#region ---- Builders ----
|
|
612
635
|
class InterfaceSelector {
|
|
613
|
-
constructor(entityRegistry, layoutBuilder, deviceService, fullName) {
|
|
636
|
+
constructor(entityRegistry, layoutBuilder, deviceService, fullName, formBuilderService) {
|
|
614
637
|
this.entityRegistry = entityRegistry;
|
|
615
638
|
this.layoutBuilder = layoutBuilder;
|
|
616
639
|
this.deviceService = deviceService;
|
|
617
640
|
this.fullName = fullName;
|
|
641
|
+
this.formBuilderService = formBuilderService;
|
|
618
642
|
}
|
|
619
643
|
create(initialData) {
|
|
620
|
-
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'create');
|
|
644
|
+
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'create', undefined, this.formBuilderService);
|
|
621
645
|
if (initialData) {
|
|
622
646
|
filter.context(initialData);
|
|
623
647
|
}
|
|
@@ -633,7 +657,7 @@ class InterfaceSelector {
|
|
|
633
657
|
initialData = data;
|
|
634
658
|
recordId = data['id'] || data['_id'];
|
|
635
659
|
}
|
|
636
|
-
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'update', recordId);
|
|
660
|
+
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'update', recordId, this.formBuilderService);
|
|
637
661
|
return filter;
|
|
638
662
|
}
|
|
639
663
|
single(data) {
|
|
@@ -646,7 +670,7 @@ class InterfaceSelector {
|
|
|
646
670
|
initialData = data;
|
|
647
671
|
recordId = data['id'] || data['_id'];
|
|
648
672
|
}
|
|
649
|
-
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'single', recordId);
|
|
673
|
+
const filter = new PropertyFilter(this.entityRegistry, this.layoutBuilder, this.deviceService, this.fullName, 'single', recordId, this.formBuilderService);
|
|
650
674
|
if (Object.keys(initialData).length > 0) {
|
|
651
675
|
filter.context(initialData);
|
|
652
676
|
}
|
|
@@ -654,12 +678,13 @@ class InterfaceSelector {
|
|
|
654
678
|
}
|
|
655
679
|
}
|
|
656
680
|
class PropertyFilter {
|
|
657
|
-
constructor(entityRegistry, layoutBuilder, deviceService, fullName, kind, recordId) {
|
|
681
|
+
constructor(entityRegistry, layoutBuilder, deviceService, fullName, kind, recordId, formBuilderService) {
|
|
658
682
|
this.entityRegistry = entityRegistry;
|
|
659
683
|
this.layoutBuilder = layoutBuilder;
|
|
660
684
|
this.deviceService = deviceService;
|
|
661
685
|
this.fullName = fullName;
|
|
662
686
|
this.kind = kind;
|
|
687
|
+
this.formBuilderService = formBuilderService;
|
|
663
688
|
this.includeList = null;
|
|
664
689
|
this.excludeList = null;
|
|
665
690
|
this.initialContext = {};
|
|
@@ -714,21 +739,28 @@ class PropertyFilter {
|
|
|
714
739
|
// Only fetch by key if we don't already have initial data
|
|
715
740
|
const hasInitialData = this.initialContext && Object.keys(this.initialContext).length > 0;
|
|
716
741
|
if ((this.kind === 'update' || this.kind === 'single') && !hasInitialData) {
|
|
717
|
-
const
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
742
|
+
const id = this.recordId;
|
|
743
|
+
if (!id) {
|
|
744
|
+
throw new Error(`Record id is required for ${this.kind}().`);
|
|
745
|
+
}
|
|
746
|
+
// Use the public method if service is available, otherwise fallback to direct entity access
|
|
747
|
+
if (this.formBuilderService) {
|
|
748
|
+
baseContext = await this.formBuilderService.getRecordById(this.fullName, id);
|
|
749
|
+
}
|
|
750
|
+
else {
|
|
751
|
+
// Fallback to original implementation if service is not available
|
|
752
|
+
const { moduleName, entityName } = parseEntityFullName(this.fullName);
|
|
753
|
+
const entity = await this.entityRegistry.resolve(moduleName, entityName);
|
|
754
|
+
try {
|
|
755
|
+
const byKeyFn = entity?.queries?.byKey?.execute;
|
|
756
|
+
if (typeof byKeyFn === 'function') {
|
|
757
|
+
baseContext = (await byKeyFn(id)) ?? {};
|
|
758
|
+
}
|
|
723
759
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
baseContext = (await byKeyFn(id)) ?? {};
|
|
760
|
+
catch {
|
|
761
|
+
baseContext = {};
|
|
727
762
|
}
|
|
728
763
|
}
|
|
729
|
-
catch {
|
|
730
|
-
baseContext = {};
|
|
731
|
-
}
|
|
732
764
|
}
|
|
733
765
|
const effectiveContext = merge({}, baseContext, this.initialContext);
|
|
734
766
|
dialog.setContext(effectiveContext);
|