@acorex/connectivity 19.1.5 → 19.1.7

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.
@@ -2,20 +2,20 @@ import { APPLICATION_SOURCE_NAME, MODULE_SOURCE_NAME, ENTITY_SOURCE_NAME, FEATUR
2
2
  import { AXMNotificationService } from '@acorex/modules/notification-management';
3
3
  import * as i1$1 from '@acorex/platform/auth';
4
4
  import { AXPSessionService, AXPAuthModule } from '@acorex/platform/auth';
5
- import { AXPDataGenerator, AXPDexieEntityStorageService, AXP_DATA_SEEDER_TOKEN, AXPEntityStorageService, AXPFileStorageStatus, AXPFileStorageService } from '@acorex/platform/common';
5
+ import { AXPDataGenerator, AXPDexieEntityStorageService, AXP_DATA_SEEDER_TOKEN, AXPEntityStorageService, AXPFileStorageStatus, AXPFileStorageService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
6
6
  import * as i0 from '@angular/core';
7
7
  import { inject, Injectable, NgModule } from '@angular/core';
8
8
  import { AXPEntityDefinitionRegistryService } from '@acorex/platform/layout/entity';
9
- import { AXMCommentService } from '@acorex/modules/backend';
10
9
  import * as i1 from '@acorex/modules/conversation';
11
10
  import { AXMConverstionModuleConst, AXMChatServiceImpl, AXMCommentServiceImpl, AXMChatModule, AXMChatService } from '@acorex/modules/conversation';
12
- import { AXMSchedulerJobManagementModuleConst } from '@acorex/modules/scheduler-job-management';
13
- import { AXMTextTemplateManagementModuleConst } from '@acorex/modules/text-template-management';
11
+ import Dexie from 'dexie';
14
12
  import { AXP_WIDGET_DATASOURCE_PROVIDER } from '@acorex/platform/layout/builder';
15
13
  import { convertArrayToDataSource } from '@acorex/components/common';
16
14
  import { AXMFormTemplateManagementModuleConst } from '@acorex/modules/form-template-management';
17
- import Dexie from 'dexie';
18
15
  import { AXFileService } from '@acorex/core/file';
16
+ import { AXMTextTemplateManagementModuleConst } from '@acorex/modules/text-template-management';
17
+ import { AXMPlatformManagementModuleConst } from '@acorex/modules/platform-management';
18
+ import { AXMSchedulerJobManagementModuleConst } from '@acorex/modules/scheduler-job-management';
19
19
 
20
20
  const APPLICATIONS = Array.from({ length: 5 }).map((_, i) => {
21
21
  const source = ['appOne', 'appTwo', 'appThree', 'myCoolApp', 'awesomeApp', 'superApp'];
@@ -490,10 +490,10 @@ class AXCConversationMockModule {
490
490
  useClass: AXPCommentDataSeeder,
491
491
  multi: true,
492
492
  },
493
- {
494
- provide: AXMCommentService,
495
- useClass: AXMCommentMockService,
496
- },
493
+ // {
494
+ // provide: AXMCommentService,
495
+ // useClass: AXMCommentMockService,
496
+ // },
497
497
  // {
498
498
  // provide: AXMChatService,
499
499
  // useClass: AXMChatMockService,
@@ -533,10 +533,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
533
533
  useClass: AXPCommentDataSeeder,
534
534
  multi: true,
535
535
  },
536
- {
537
- provide: AXMCommentService,
538
- useClass: AXMCommentMockService,
539
- },
536
+ // {
537
+ // provide: AXMCommentService,
538
+ // useClass: AXMCommentMockService,
539
+ // },
540
540
  // {
541
541
  // provide: AXMChatService,
542
542
  // useClass: AXMChatMockService,
@@ -545,6 +545,137 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
545
545
  }]
546
546
  }] });
547
547
 
548
+ class EntitySearchProvider {
549
+ async search(text) {
550
+ const db = new Dexie('ACoreXPlatform');
551
+ const lowerText = text.toLowerCase(); // Normalize search text for case-insensitive search
552
+ db.version(1).stores({
553
+ 'entity-store': '++id, entityName, [entityName+id]',
554
+ });
555
+ // Fetch all records from the entity-store table
556
+ const allRecords = await db.table('entity-store').toArray();
557
+ // Filter records based on the search text
558
+ const filteredRecords = allRecords.filter((record) => this.shallowSearch(record, lowerText));
559
+ debugger;
560
+ return filteredRecords.map((record) => ({
561
+ title: record.title || '',
562
+ name: `record.${record.entityName}`,
563
+ description: record.description,
564
+ icon: record.icon,
565
+ data: record,
566
+ }));
567
+ }
568
+ // Helper function for shallow search
569
+ shallowSearch(obj, text) {
570
+ if (typeof obj !== 'object' || obj === null) {
571
+ return false;
572
+ }
573
+ return Object.entries(obj).some(([key, value]) => {
574
+ if (typeof value === 'string' || typeof value === 'number') {
575
+ return value.toString().toLowerCase().includes(text);
576
+ }
577
+ return false;
578
+ });
579
+ }
580
+ }
581
+
582
+ class AXPMockWidgetDataSourceProvider {
583
+ async items() {
584
+ return [
585
+ {
586
+ name: 'mock.users',
587
+ title: 'Users',
588
+ columns: [],
589
+ samples: [
590
+ {
591
+ id: '2',
592
+ title: 'Alex Jakson',
593
+ },
594
+ {
595
+ id: '3',
596
+ title: 'Emma Smith',
597
+ },
598
+ ],
599
+ source: () => convertArrayToDataSource([
600
+ {
601
+ id: '1',
602
+ title: 'Arash Oshnoudi',
603
+ },
604
+ {
605
+ id: '2',
606
+ title: 'Alex Smith',
607
+ },
608
+ {
609
+ id: '3',
610
+ title: 'Emma Jakson',
611
+ },
612
+ ]),
613
+ },
614
+ ];
615
+ }
616
+ }
617
+
618
+ class AXPFormTemplateCategoryDataSeeder {
619
+ constructor() {
620
+ this.storageService = inject(AXPDexieEntityStorageService);
621
+ }
622
+ async seed() {
623
+ await this.storageService.initial(`${AXMFormTemplateManagementModuleConst.moduleName}.${AXMFormTemplateManagementModuleConst.categoryEntity}`, [
624
+ {
625
+ title: 'Risk Assessment'
626
+ },
627
+ {
628
+ title: 'Servicing'
629
+ },
630
+ {
631
+ title: 'Checklists'
632
+ }
633
+ ]);
634
+ }
635
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
636
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder }); }
637
+ }
638
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, decorators: [{
639
+ type: Injectable
640
+ }] });
641
+
642
+ class AXCFormTemplateManagementMockModule {
643
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
644
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule }); }
645
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, providers: [
646
+ {
647
+ provide: AXP_WIDGET_DATASOURCE_PROVIDER,
648
+ useClass: AXPMockWidgetDataSourceProvider,
649
+ multi: true,
650
+ },
651
+ {
652
+ provide: AXP_DATA_SEEDER_TOKEN,
653
+ useClass: AXPFormTemplateCategoryDataSeeder,
654
+ multi: true,
655
+ },
656
+ ] }); }
657
+ }
658
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, decorators: [{
659
+ type: NgModule,
660
+ args: [{
661
+ imports: [],
662
+ exports: [],
663
+ declarations: [],
664
+ providers: [
665
+ {
666
+ provide: AXP_WIDGET_DATASOURCE_PROVIDER,
667
+ useClass: AXPMockWidgetDataSourceProvider,
668
+ multi: true,
669
+ },
670
+ {
671
+ provide: AXP_DATA_SEEDER_TOKEN,
672
+ useClass: AXPFormTemplateCategoryDataSeeder,
673
+ multi: true,
674
+ },
675
+ ],
676
+ }]
677
+ }] });
678
+
548
679
  class MOCKStrategy {
549
680
  constructor() { }
550
681
  get name() {
@@ -699,7 +830,7 @@ function generateNotification() {
699
830
  }
700
831
 
701
832
  const names = ['key', 'counter', 'logo', 'tenant'];
702
- const data = [
833
+ const data$1 = [
703
834
  ['key1', 'string'],
704
835
  ['sequence', 'integer'],
705
836
  ['appLogo', 'function'],
@@ -710,8 +841,8 @@ const GLOBAL_VARIABLES = Array.from({ length: 4 }).map((element, i) => {
710
841
  id: AXPDataGenerator.uuid(),
711
842
  name: names[i],
712
843
  title: names[i],
713
- dataType: data[i][1],
714
- dataValue: data[i][0],
844
+ dataType: data$1[i][1],
845
+ dataValue: data$1[i][0],
715
846
  };
716
847
  });
717
848
 
@@ -729,6 +860,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
729
860
  type: Injectable
730
861
  }] });
731
862
 
863
+ class FileStorageDatabase extends Dexie {
864
+ constructor() {
865
+ super('FileStorageDatabase');
866
+ this.version(1).stores({
867
+ files: 'fileId,refId,refType,category,isPrimary,status',
868
+ });
869
+ }
870
+ }
871
+ const db = new FileStorageDatabase();
872
+ class AXCFileStorageService {
873
+ async mapToFileStorageInfo(record) {
874
+ if (!record) {
875
+ throw new Error('Record not found');
876
+ }
877
+ const { binary, ...fileInfo } = record;
878
+ const url = await this.fileService.blobToBase64(binary);
879
+ return { ...fileInfo, url };
880
+ }
881
+ async save(request) {
882
+ const fileId = crypto.randomUUID();
883
+ const fileInfo = {
884
+ fileId,
885
+ refId: request.refId,
886
+ refType: request.refType,
887
+ category: request.category,
888
+ size: request.file.size,
889
+ mimeType: request.file.type,
890
+ uploadedAt: new Date(),
891
+ isPublic: request.metadata?.["isPublic"] || true,
892
+ isPrimary: request.isPrimary || false,
893
+ status: AXPFileStorageStatus.Temporary, // Use enum
894
+ };
895
+ // Save the binary content along with metadata in Dexie
896
+ await db.files.add({ ...fileInfo, binary: request.file });
897
+ return fileInfo;
898
+ }
899
+ async commit(fileId) {
900
+ const file = await db.files.get(fileId);
901
+ if (!file) {
902
+ throw new Error('File not found');
903
+ }
904
+ file.status = AXPFileStorageStatus.Committed; // Use enum
905
+ await db.files.put(file);
906
+ }
907
+ async markForDeletion(fileId) {
908
+ const file = await db.files.get(fileId);
909
+ if (!file) {
910
+ throw new Error('File not found');
911
+ }
912
+ file.status = AXPFileStorageStatus.PendingDeletion; // Use enum
913
+ await db.files.put(file);
914
+ }
915
+ async update(request) {
916
+ const file = await db.files.get(request.fileId);
917
+ if (!file) {
918
+ throw new Error('File not found');
919
+ }
920
+ const updatedFileInfo = {
921
+ ...file,
922
+ ...request.metadata,
923
+ isPrimary: request.isPrimary !== undefined ? request.isPrimary : file.isPrimary,
924
+ };
925
+ await db.files.put(updatedFileInfo);
926
+ return this.mapToFileStorageInfo(updatedFileInfo);
927
+ }
928
+ async find(request) {
929
+ const files = await db.files.toArray();
930
+ const filteredFiles = files.filter((file) => {
931
+ return ((!request.refId || file.refId === request.refId) &&
932
+ (!request.refType || file.refType === request.refType) &&
933
+ (!request.category || file.category === request.category) &&
934
+ (!request.isPrimary || file.isPrimary === request.isPrimary) &&
935
+ (!request.isPublic || file.isPublic === request.isPublic) &&
936
+ (!request.mimeType || file.mimeType === request.mimeType) &&
937
+ (!request.uploadedAtRange ||
938
+ (file.uploadedAt >= request.uploadedAtRange.from &&
939
+ file.uploadedAt <= request.uploadedAtRange.to)) &&
940
+ file.status === AXPFileStorageStatus.Committed // Use enum
941
+ );
942
+ });
943
+ // Map all filtered files to `AXPFileStorageInfo`
944
+ return Promise.all(filteredFiles.map((file) => this.mapToFileStorageInfo(file)));
945
+ }
946
+ async getInfo(fileId) {
947
+ // Simulate a delay of 2 seconds (2000 milliseconds)
948
+ await new Promise((resolve) => setTimeout(resolve, 2000));
949
+ const file = await db.files.get(fileId);
950
+ return this.mapToFileStorageInfo(file);
951
+ }
952
+ async remove(fileId) {
953
+ await db.files.delete(fileId);
954
+ }
955
+ async cleanupTemporaryFiles() {
956
+ const files = await db.files.toArray();
957
+ const temporaryFiles = files.filter((file) => file.status === AXPFileStorageStatus.Temporary);
958
+ for (const file of temporaryFiles) {
959
+ await db.files.delete(file.fileId);
960
+ }
961
+ }
962
+ async cleanupMarkedFiles(gracePeriod) {
963
+ const now = new Date();
964
+ const files = await db.files.toArray();
965
+ for (const file of files) {
966
+ if (file.status === AXPFileStorageStatus.PendingDeletion &&
967
+ now.getTime() - file.uploadedAt.getTime() > gracePeriod) {
968
+ await db.files.delete(file.fileId);
969
+ }
970
+ }
971
+ }
972
+ // Semi-background cleanup job
973
+ constructor() {
974
+ this.fileService = inject(AXFileService);
975
+ setInterval(() => {
976
+ this.cleanupMarkedFiles(5 * 60 * 1000) // Grace period: 5 minutes in milliseconds
977
+ .catch((error) => console.error('Error during cleanup:', error));
978
+ this.cleanupTemporaryFiles() // Ensure temporary files are cleaned
979
+ .catch((error) => console.error('Error during cleanup:', error));
980
+ }, 5 * 60 * 1000); // Runs every 5 minutes
981
+ }
982
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
983
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService }); }
984
+ }
985
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, decorators: [{
986
+ type: Injectable
987
+ }], ctorParameters: () => [] });
988
+
989
+ const data = [
990
+ ['key1', 'string'],
991
+ ['sequence', 'integer'],
992
+ ['appLogo', 'function'],
993
+ ['CompanyName', 'function'],
994
+ ];
995
+ const TEXT_SEARCH_DATA = Array.from({ length: 4 }).map((element, i) => {
996
+ return {
997
+ id: AXPDataGenerator.uuid(),
998
+ name: `${AXMTextTemplateManagementModuleConst.moduleName}.${AXMTextTemplateManagementModuleConst.categoryEntity}`,
999
+ title: data[i][0],
1000
+ subtitle: data[i][1],
1001
+ entityId: AXPDataGenerator.uuid(),
1002
+ entityType: `${AXMTextTemplateManagementModuleConst.moduleName}.${AXMTextTemplateManagementModuleConst.categoryEntity}`,
1003
+ };
1004
+ });
1005
+
1006
+ class AXPTextSearchDataSeeder {
1007
+ constructor() {
1008
+ this.storageService = inject(AXPDexieEntityStorageService);
1009
+ }
1010
+ async seed() {
1011
+ await this.storageService.initial(`${AXMPlatformManagementModuleConst.moduleName}.${AXMPlatformManagementModuleConst.textSearchEntity}`, TEXT_SEARCH_DATA);
1012
+ }
1013
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1014
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder }); }
1015
+ }
1016
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder, decorators: [{
1017
+ type: Injectable
1018
+ }] });
1019
+
732
1020
  const SCHEDULER_JOB = [
733
1021
  {
734
1022
  id: AXPDataGenerator.uuid(),
@@ -905,229 +1193,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
905
1193
  type: Injectable
906
1194
  }] });
907
1195
 
908
- class AXPMockWidgetDataSourceProvider {
909
- async items() {
910
- return [
911
- {
912
- name: 'mock.users',
913
- title: 'Users',
914
- columns: [],
915
- samples: [
916
- {
917
- id: '2',
918
- title: 'Alex Jakson',
919
- },
920
- {
921
- id: '3',
922
- title: 'Emma Smith',
923
- },
924
- ],
925
- source: () => convertArrayToDataSource([
926
- {
927
- id: '1',
928
- title: 'Arash Oshnoudi',
929
- },
930
- {
931
- id: '2',
932
- title: 'Alex Smith',
933
- },
934
- {
935
- id: '3',
936
- title: 'Emma Jakson',
937
- },
938
- ]),
939
- },
940
- ];
941
- }
942
- }
943
-
944
- class AXPFormTemplateCategoryDataSeeder {
945
- constructor() {
946
- this.storageService = inject(AXPDexieEntityStorageService);
947
- }
948
- async seed() {
949
- await this.storageService.initial(`${AXMFormTemplateManagementModuleConst.moduleName}.${AXMFormTemplateManagementModuleConst.categoryEntity}`, [
950
- {
951
- title: 'Risk Assessment'
952
- },
953
- {
954
- title: 'Servicing'
955
- },
956
- {
957
- title: 'Checklists'
958
- }
959
- ]);
960
- }
961
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
962
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder }); }
963
- }
964
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, decorators: [{
965
- type: Injectable
966
- }] });
967
-
968
- class AXCFormTemplateManagementMockModule {
969
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
970
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule }); }
971
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, providers: [
972
- {
973
- provide: AXP_WIDGET_DATASOURCE_PROVIDER,
974
- useClass: AXPMockWidgetDataSourceProvider,
975
- multi: true,
976
- },
977
- {
978
- provide: AXP_DATA_SEEDER_TOKEN,
979
- useClass: AXPFormTemplateCategoryDataSeeder,
980
- multi: true,
981
- },
982
- ] }); }
983
- }
984
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, decorators: [{
985
- type: NgModule,
986
- args: [{
987
- imports: [],
988
- exports: [],
989
- declarations: [],
990
- providers: [
991
- {
992
- provide: AXP_WIDGET_DATASOURCE_PROVIDER,
993
- useClass: AXPMockWidgetDataSourceProvider,
994
- multi: true,
995
- },
996
- {
997
- provide: AXP_DATA_SEEDER_TOKEN,
998
- useClass: AXPFormTemplateCategoryDataSeeder,
999
- multi: true,
1000
- },
1001
- ],
1002
- }]
1003
- }] });
1004
-
1005
- class FileStorageDatabase extends Dexie {
1006
- constructor() {
1007
- super('FileStorageDatabase');
1008
- this.version(1).stores({
1009
- files: 'fileId,refId,refType,category,isPrimary,status',
1010
- });
1011
- }
1012
- }
1013
- const db = new FileStorageDatabase();
1014
- class AXCFileStorageService {
1015
- async mapToFileStorageInfo(record) {
1016
- if (!record) {
1017
- throw new Error('Record not found');
1018
- }
1019
- const { binary, ...fileInfo } = record;
1020
- const url = await this.fileService.blobToBase64(binary);
1021
- return { ...fileInfo, url };
1022
- }
1023
- async save(request) {
1024
- const fileId = crypto.randomUUID();
1025
- const fileInfo = {
1026
- fileId,
1027
- refId: request.refId,
1028
- refType: request.refType,
1029
- category: request.category,
1030
- size: request.file.size,
1031
- mimeType: request.file.type,
1032
- uploadedAt: new Date(),
1033
- isPublic: request.metadata?.["isPublic"] || true,
1034
- isPrimary: request.isPrimary || false,
1035
- status: AXPFileStorageStatus.Temporary, // Use enum
1036
- };
1037
- // Save the binary content along with metadata in Dexie
1038
- await db.files.add({ ...fileInfo, binary: request.file });
1039
- return fileInfo;
1040
- }
1041
- async commit(fileId) {
1042
- const file = await db.files.get(fileId);
1043
- if (!file) {
1044
- throw new Error('File not found');
1045
- }
1046
- file.status = AXPFileStorageStatus.Committed; // Use enum
1047
- await db.files.put(file);
1048
- }
1049
- async markForDeletion(fileId) {
1050
- const file = await db.files.get(fileId);
1051
- if (!file) {
1052
- throw new Error('File not found');
1053
- }
1054
- file.status = AXPFileStorageStatus.PendingDeletion; // Use enum
1055
- await db.files.put(file);
1056
- }
1057
- async update(request) {
1058
- const file = await db.files.get(request.fileId);
1059
- if (!file) {
1060
- throw new Error('File not found');
1061
- }
1062
- const updatedFileInfo = {
1063
- ...file,
1064
- ...request.metadata,
1065
- isPrimary: request.isPrimary !== undefined ? request.isPrimary : file.isPrimary,
1066
- };
1067
- await db.files.put(updatedFileInfo);
1068
- return this.mapToFileStorageInfo(updatedFileInfo);
1069
- }
1070
- async find(request) {
1071
- const files = await db.files.toArray();
1072
- const filteredFiles = files.filter((file) => {
1073
- return ((!request.refId || file.refId === request.refId) &&
1074
- (!request.refType || file.refType === request.refType) &&
1075
- (!request.category || file.category === request.category) &&
1076
- (!request.isPrimary || file.isPrimary === request.isPrimary) &&
1077
- (!request.isPublic || file.isPublic === request.isPublic) &&
1078
- (!request.mimeType || file.mimeType === request.mimeType) &&
1079
- (!request.uploadedAtRange ||
1080
- (file.uploadedAt >= request.uploadedAtRange.from &&
1081
- file.uploadedAt <= request.uploadedAtRange.to)) &&
1082
- file.status === AXPFileStorageStatus.Committed // Use enum
1083
- );
1084
- });
1085
- // Map all filtered files to `AXPFileStorageInfo`
1086
- return Promise.all(filteredFiles.map((file) => this.mapToFileStorageInfo(file)));
1087
- }
1088
- async getInfo(fileId) {
1089
- // Simulate a delay of 2 seconds (2000 milliseconds)
1090
- await new Promise((resolve) => setTimeout(resolve, 2000));
1091
- const file = await db.files.get(fileId);
1092
- return this.mapToFileStorageInfo(file);
1093
- }
1094
- async remove(fileId) {
1095
- await db.files.delete(fileId);
1096
- }
1097
- async cleanupTemporaryFiles() {
1098
- const files = await db.files.toArray();
1099
- const temporaryFiles = files.filter((file) => file.status === AXPFileStorageStatus.Temporary);
1100
- for (const file of temporaryFiles) {
1101
- await db.files.delete(file.fileId);
1102
- }
1103
- }
1104
- async cleanupMarkedFiles(gracePeriod) {
1105
- const now = new Date();
1106
- const files = await db.files.toArray();
1107
- for (const file of files) {
1108
- if (file.status === AXPFileStorageStatus.PendingDeletion &&
1109
- now.getTime() - file.uploadedAt.getTime() > gracePeriod) {
1110
- await db.files.delete(file.fileId);
1111
- }
1112
- }
1113
- }
1114
- // Semi-background cleanup job
1115
- constructor() {
1116
- this.fileService = inject(AXFileService);
1117
- setInterval(() => {
1118
- this.cleanupMarkedFiles(5 * 60 * 1000) // Grace period: 5 minutes in milliseconds
1119
- .catch((error) => console.error('Error during cleanup:', error));
1120
- this.cleanupTemporaryFiles() // Ensure temporary files are cleaned
1121
- .catch((error) => console.error('Error during cleanup:', error));
1122
- }, 5 * 60 * 1000); // Runs every 5 minutes
1123
- }
1124
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1125
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService }); }
1126
- }
1127
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, decorators: [{
1128
- type: Injectable
1129
- }], ctorParameters: () => [] });
1130
-
1131
1196
  class AXCMockModule {
1132
1197
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1133
1198
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXCMockModule, imports: [i1$1.AXPAuthModule, AXCFormTemplateManagementMockModule,
@@ -1167,6 +1232,11 @@ class AXCMockModule {
1167
1232
  useClass: AXPSchedulerJobDataSeeder,
1168
1233
  multi: true,
1169
1234
  },
1235
+ {
1236
+ provide: AXP_DATA_SEEDER_TOKEN,
1237
+ useClass: AXPTextSearchDataSeeder,
1238
+ multi: true,
1239
+ },
1170
1240
  {
1171
1241
  provide: AXPModuleDesignerService,
1172
1242
  useClass: AXCModuleDesignerService,
@@ -1175,6 +1245,11 @@ class AXCMockModule {
1175
1245
  provide: AXPFileStorageService,
1176
1246
  useClass: AXCFileStorageService,
1177
1247
  },
1248
+ {
1249
+ provide: AXP_SEARCH_PROVIDER,
1250
+ useClass: EntitySearchProvider,
1251
+ multi: true,
1252
+ },
1178
1253
  ], imports: [AXPAuthModule.forRoot({
1179
1254
  strategies: [MOCKStrategy],
1180
1255
  }),
@@ -1228,6 +1303,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1228
1303
  useClass: AXPSchedulerJobDataSeeder,
1229
1304
  multi: true,
1230
1305
  },
1306
+ {
1307
+ provide: AXP_DATA_SEEDER_TOKEN,
1308
+ useClass: AXPTextSearchDataSeeder,
1309
+ multi: true,
1310
+ },
1231
1311
  {
1232
1312
  provide: AXPModuleDesignerService,
1233
1313
  useClass: AXCModuleDesignerService,
@@ -1236,6 +1316,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1236
1316
  provide: AXPFileStorageService,
1237
1317
  useClass: AXCFileStorageService,
1238
1318
  },
1319
+ {
1320
+ provide: AXP_SEARCH_PROVIDER,
1321
+ useClass: EntitySearchProvider,
1322
+ multi: true,
1323
+ },
1239
1324
  ],
1240
1325
  }]
1241
1326
  }] });