@acorex/connectivity 19.1.6 → 19.1.8

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'];
@@ -440,7 +440,6 @@ class AXMCommentMockService extends AXMCommentServiceImpl {
440
440
  return 'done';
441
441
  }
442
442
  async like(payload) {
443
- debugger;
444
443
  const comment = await super.getOne(payload.messageId);
445
444
  if (comment) {
446
445
  const isLiked = !comment.isLiked;
@@ -490,10 +489,10 @@ class AXCConversationMockModule {
490
489
  useClass: AXPCommentDataSeeder,
491
490
  multi: true,
492
491
  },
493
- {
494
- provide: AXMCommentService,
495
- useClass: AXMCommentMockService,
496
- },
492
+ // {
493
+ // provide: AXMCommentService,
494
+ // useClass: AXMCommentMockService,
495
+ // },
497
496
  // {
498
497
  // provide: AXMChatService,
499
498
  // useClass: AXMChatMockService,
@@ -533,10 +532,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
533
532
  useClass: AXPCommentDataSeeder,
534
533
  multi: true,
535
534
  },
536
- {
537
- provide: AXMCommentService,
538
- useClass: AXMCommentMockService,
539
- },
535
+ // {
536
+ // provide: AXMCommentService,
537
+ // useClass: AXMCommentMockService,
538
+ // },
540
539
  // {
541
540
  // provide: AXMChatService,
542
541
  // useClass: AXMChatMockService,
@@ -545,6 +544,141 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
545
544
  }]
546
545
  }] });
547
546
 
547
+ class EntitySearchProvider {
548
+ async search(text) {
549
+ const db = new Dexie('ACoreXPlatform');
550
+ const lowerText = text.toLowerCase(); // Normalize search text for case-insensitive search
551
+ db.version(1).stores({
552
+ 'entity-store': '++id, entityName, [entityName+id]',
553
+ });
554
+ // Fetch all records from the entity-store table
555
+ const allRecords = await db.table('entity-store').toArray();
556
+ // Filter records based on the search text
557
+ const filteredRecords = allRecords.filter((record) => this.shallowSearch(record, lowerText));
558
+ return filteredRecords.map((record) => ({
559
+ title: record.title || '',
560
+ name: `record.${record.entityName}`,
561
+ description: record.description,
562
+ icon: record.icon,
563
+ data: record,
564
+ }));
565
+ }
566
+ // Helper function for shallow search
567
+ shallowSearch(obj, text) {
568
+ if (typeof obj !== 'object' || obj === null) {
569
+ return false;
570
+ }
571
+ return Object.entries(obj).some(([key, value]) => {
572
+ if (key != 'id' && key != 'entityName') {
573
+ if (typeof value === 'string' || typeof value === 'number') {
574
+ return value.toString().toLowerCase().includes(text);
575
+ }
576
+ return false;
577
+ }
578
+ else {
579
+ return false;
580
+ }
581
+ });
582
+ }
583
+ }
584
+
585
+ class AXPMockWidgetDataSourceProvider {
586
+ async items() {
587
+ return [
588
+ {
589
+ name: 'mock.users',
590
+ title: 'Users',
591
+ columns: [],
592
+ samples: [
593
+ {
594
+ id: '2',
595
+ title: 'Alex Jakson',
596
+ },
597
+ {
598
+ id: '3',
599
+ title: 'Emma Smith',
600
+ },
601
+ ],
602
+ source: () => convertArrayToDataSource([
603
+ {
604
+ id: '1',
605
+ title: 'Arash Oshnoudi',
606
+ },
607
+ {
608
+ id: '2',
609
+ title: 'Alex Smith',
610
+ },
611
+ {
612
+ id: '3',
613
+ title: 'Emma Jakson',
614
+ },
615
+ ]),
616
+ },
617
+ ];
618
+ }
619
+ }
620
+
621
+ class AXPFormTemplateCategoryDataSeeder {
622
+ constructor() {
623
+ this.storageService = inject(AXPDexieEntityStorageService);
624
+ }
625
+ async seed() {
626
+ await this.storageService.initial(`${AXMFormTemplateManagementModuleConst.moduleName}.${AXMFormTemplateManagementModuleConst.categoryEntity}`, [
627
+ {
628
+ title: 'Risk Assessment'
629
+ },
630
+ {
631
+ title: 'Servicing'
632
+ },
633
+ {
634
+ title: 'Checklists'
635
+ }
636
+ ]);
637
+ }
638
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
639
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder }); }
640
+ }
641
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPFormTemplateCategoryDataSeeder, decorators: [{
642
+ type: Injectable
643
+ }] });
644
+
645
+ class AXCFormTemplateManagementMockModule {
646
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
647
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule }); }
648
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, providers: [
649
+ {
650
+ provide: AXP_WIDGET_DATASOURCE_PROVIDER,
651
+ useClass: AXPMockWidgetDataSourceProvider,
652
+ multi: true,
653
+ },
654
+ {
655
+ provide: AXP_DATA_SEEDER_TOKEN,
656
+ useClass: AXPFormTemplateCategoryDataSeeder,
657
+ multi: true,
658
+ },
659
+ ] }); }
660
+ }
661
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFormTemplateManagementMockModule, decorators: [{
662
+ type: NgModule,
663
+ args: [{
664
+ imports: [],
665
+ exports: [],
666
+ declarations: [],
667
+ providers: [
668
+ {
669
+ provide: AXP_WIDGET_DATASOURCE_PROVIDER,
670
+ useClass: AXPMockWidgetDataSourceProvider,
671
+ multi: true,
672
+ },
673
+ {
674
+ provide: AXP_DATA_SEEDER_TOKEN,
675
+ useClass: AXPFormTemplateCategoryDataSeeder,
676
+ multi: true,
677
+ },
678
+ ],
679
+ }]
680
+ }] });
681
+
548
682
  class MOCKStrategy {
549
683
  constructor() { }
550
684
  get name() {
@@ -699,7 +833,7 @@ function generateNotification() {
699
833
  }
700
834
 
701
835
  const names = ['key', 'counter', 'logo', 'tenant'];
702
- const data = [
836
+ const data$1 = [
703
837
  ['key1', 'string'],
704
838
  ['sequence', 'integer'],
705
839
  ['appLogo', 'function'],
@@ -710,8 +844,8 @@ const GLOBAL_VARIABLES = Array.from({ length: 4 }).map((element, i) => {
710
844
  id: AXPDataGenerator.uuid(),
711
845
  name: names[i],
712
846
  title: names[i],
713
- dataType: data[i][1],
714
- dataValue: data[i][0],
847
+ dataType: data$1[i][1],
848
+ dataValue: data$1[i][0],
715
849
  };
716
850
  });
717
851
 
@@ -729,6 +863,163 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
729
863
  type: Injectable
730
864
  }] });
731
865
 
866
+ class FileStorageDatabase extends Dexie {
867
+ constructor() {
868
+ super('FileStorageDatabase');
869
+ this.version(1).stores({
870
+ files: 'fileId,refId,refType,category,isPrimary,status',
871
+ });
872
+ }
873
+ }
874
+ const db = new FileStorageDatabase();
875
+ class AXCFileStorageService {
876
+ async mapToFileStorageInfo(record) {
877
+ if (!record) {
878
+ throw new Error('Record not found');
879
+ }
880
+ const { binary, ...fileInfo } = record;
881
+ const url = await this.fileService.blobToBase64(binary);
882
+ return { ...fileInfo, url };
883
+ }
884
+ async save(request) {
885
+ const fileId = crypto.randomUUID();
886
+ const fileInfo = {
887
+ fileId,
888
+ refId: request.refId,
889
+ refType: request.refType,
890
+ category: request.category,
891
+ size: request.file.size,
892
+ mimeType: request.file.type,
893
+ uploadedAt: new Date(),
894
+ isPublic: request.metadata?.["isPublic"] || true,
895
+ isPrimary: request.isPrimary || false,
896
+ status: AXPFileStorageStatus.Temporary, // Use enum
897
+ };
898
+ // Save the binary content along with metadata in Dexie
899
+ await db.files.add({ ...fileInfo, binary: request.file });
900
+ return fileInfo;
901
+ }
902
+ async commit(fileId) {
903
+ const file = await db.files.get(fileId);
904
+ if (!file) {
905
+ throw new Error('File not found');
906
+ }
907
+ file.status = AXPFileStorageStatus.Committed; // Use enum
908
+ await db.files.put(file);
909
+ }
910
+ async markForDeletion(fileId) {
911
+ const file = await db.files.get(fileId);
912
+ if (!file) {
913
+ throw new Error('File not found');
914
+ }
915
+ file.status = AXPFileStorageStatus.PendingDeletion; // Use enum
916
+ await db.files.put(file);
917
+ }
918
+ async update(request) {
919
+ const file = await db.files.get(request.fileId);
920
+ if (!file) {
921
+ throw new Error('File not found');
922
+ }
923
+ const updatedFileInfo = {
924
+ ...file,
925
+ ...request.metadata,
926
+ isPrimary: request.isPrimary !== undefined ? request.isPrimary : file.isPrimary,
927
+ };
928
+ await db.files.put(updatedFileInfo);
929
+ return this.mapToFileStorageInfo(updatedFileInfo);
930
+ }
931
+ async find(request) {
932
+ const files = await db.files.toArray();
933
+ const filteredFiles = files.filter((file) => {
934
+ return ((!request.refId || file.refId === request.refId) &&
935
+ (!request.refType || file.refType === request.refType) &&
936
+ (!request.category || file.category === request.category) &&
937
+ (!request.isPrimary || file.isPrimary === request.isPrimary) &&
938
+ (!request.isPublic || file.isPublic === request.isPublic) &&
939
+ (!request.mimeType || file.mimeType === request.mimeType) &&
940
+ (!request.uploadedAtRange ||
941
+ (file.uploadedAt >= request.uploadedAtRange.from &&
942
+ file.uploadedAt <= request.uploadedAtRange.to)) &&
943
+ file.status === AXPFileStorageStatus.Committed // Use enum
944
+ );
945
+ });
946
+ // Map all filtered files to `AXPFileStorageInfo`
947
+ return Promise.all(filteredFiles.map((file) => this.mapToFileStorageInfo(file)));
948
+ }
949
+ async getInfo(fileId) {
950
+ // Simulate a delay of 2 seconds (2000 milliseconds)
951
+ await new Promise((resolve) => setTimeout(resolve, 2000));
952
+ const file = await db.files.get(fileId);
953
+ return this.mapToFileStorageInfo(file);
954
+ }
955
+ async remove(fileId) {
956
+ await db.files.delete(fileId);
957
+ }
958
+ async cleanupTemporaryFiles() {
959
+ const files = await db.files.toArray();
960
+ const temporaryFiles = files.filter((file) => file.status === AXPFileStorageStatus.Temporary);
961
+ for (const file of temporaryFiles) {
962
+ await db.files.delete(file.fileId);
963
+ }
964
+ }
965
+ async cleanupMarkedFiles(gracePeriod) {
966
+ const now = new Date();
967
+ const files = await db.files.toArray();
968
+ for (const file of files) {
969
+ if (file.status === AXPFileStorageStatus.PendingDeletion &&
970
+ now.getTime() - file.uploadedAt.getTime() > gracePeriod) {
971
+ await db.files.delete(file.fileId);
972
+ }
973
+ }
974
+ }
975
+ // Semi-background cleanup job
976
+ constructor() {
977
+ this.fileService = inject(AXFileService);
978
+ setInterval(() => {
979
+ this.cleanupMarkedFiles(5 * 60 * 1000) // Grace period: 5 minutes in milliseconds
980
+ .catch((error) => console.error('Error during cleanup:', error));
981
+ this.cleanupTemporaryFiles() // Ensure temporary files are cleaned
982
+ .catch((error) => console.error('Error during cleanup:', error));
983
+ }, 5 * 60 * 1000); // Runs every 5 minutes
984
+ }
985
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
986
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService }); }
987
+ }
988
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileStorageService, decorators: [{
989
+ type: Injectable
990
+ }], ctorParameters: () => [] });
991
+
992
+ const data = [
993
+ ['key1', 'string'],
994
+ ['sequence', 'integer'],
995
+ ['appLogo', 'function'],
996
+ ['CompanyName', 'function'],
997
+ ];
998
+ const TEXT_SEARCH_DATA = Array.from({ length: 4 }).map((element, i) => {
999
+ return {
1000
+ id: AXPDataGenerator.uuid(),
1001
+ name: `${AXMTextTemplateManagementModuleConst.moduleName}.${AXMTextTemplateManagementModuleConst.categoryEntity}`,
1002
+ title: data[i][0],
1003
+ subtitle: data[i][1],
1004
+ entityId: AXPDataGenerator.uuid(),
1005
+ entityType: `${AXMTextTemplateManagementModuleConst.moduleName}.${AXMTextTemplateManagementModuleConst.categoryEntity}`,
1006
+ };
1007
+ });
1008
+
1009
+ class AXPTextSearchDataSeeder {
1010
+ constructor() {
1011
+ this.storageService = inject(AXPDexieEntityStorageService);
1012
+ }
1013
+ async seed() {
1014
+ await this.storageService.initial(`${AXMPlatformManagementModuleConst.moduleName}.${AXMPlatformManagementModuleConst.textSearchEntity}`, TEXT_SEARCH_DATA);
1015
+ }
1016
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1017
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder }); }
1018
+ }
1019
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXPTextSearchDataSeeder, decorators: [{
1020
+ type: Injectable
1021
+ }] });
1022
+
732
1023
  const SCHEDULER_JOB = [
733
1024
  {
734
1025
  id: AXPDataGenerator.uuid(),
@@ -905,229 +1196,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
905
1196
  type: Injectable
906
1197
  }] });
907
1198
 
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
1199
  class AXCMockModule {
1132
1200
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1133
1201
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.3", ngImport: i0, type: AXCMockModule, imports: [i1$1.AXPAuthModule, AXCFormTemplateManagementMockModule,
@@ -1167,6 +1235,11 @@ class AXCMockModule {
1167
1235
  useClass: AXPSchedulerJobDataSeeder,
1168
1236
  multi: true,
1169
1237
  },
1238
+ {
1239
+ provide: AXP_DATA_SEEDER_TOKEN,
1240
+ useClass: AXPTextSearchDataSeeder,
1241
+ multi: true,
1242
+ },
1170
1243
  {
1171
1244
  provide: AXPModuleDesignerService,
1172
1245
  useClass: AXCModuleDesignerService,
@@ -1175,6 +1248,11 @@ class AXCMockModule {
1175
1248
  provide: AXPFileStorageService,
1176
1249
  useClass: AXCFileStorageService,
1177
1250
  },
1251
+ {
1252
+ provide: AXP_SEARCH_PROVIDER,
1253
+ useClass: EntitySearchProvider,
1254
+ multi: true,
1255
+ },
1178
1256
  ], imports: [AXPAuthModule.forRoot({
1179
1257
  strategies: [MOCKStrategy],
1180
1258
  }),
@@ -1228,6 +1306,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1228
1306
  useClass: AXPSchedulerJobDataSeeder,
1229
1307
  multi: true,
1230
1308
  },
1309
+ {
1310
+ provide: AXP_DATA_SEEDER_TOKEN,
1311
+ useClass: AXPTextSearchDataSeeder,
1312
+ multi: true,
1313
+ },
1231
1314
  {
1232
1315
  provide: AXPModuleDesignerService,
1233
1316
  useClass: AXCModuleDesignerService,
@@ -1236,6 +1319,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
1236
1319
  provide: AXPFileStorageService,
1237
1320
  useClass: AXCFileStorageService,
1238
1321
  },
1322
+ {
1323
+ provide: AXP_SEARCH_PROVIDER,
1324
+ useClass: EntitySearchProvider,
1325
+ multi: true,
1326
+ },
1239
1327
  ],
1240
1328
  }]
1241
1329
  }] });