@dataclouder/ngx-core 0.2.1 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataclouder/ngx-core",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Angular core components library for DataClouder applications, only for internal use",
5
5
  "author": {
6
6
  "name": "dataclouder",
@@ -687,10 +687,13 @@ declare class HttpCoreService {
687
687
  static ɵprov: i0.ɵɵInjectableDeclaration<HttpCoreService>;
688
688
  }
689
689
 
690
+ type EntityViewMode = 'list' | 'form' | 'detail';
690
691
  declare abstract class EntityCommunicationService<T> {
691
692
  protected serviceName: string;
692
693
  protected httpService: HttpCoreService;
693
694
  protected customHost?: string;
695
+ currentEntity: WritableSignal<T | undefined>;
696
+ currentMode: WritableSignal<EntityViewMode | undefined>;
694
697
  constructor(serviceName: string);
695
698
  findAll(query?: any): Promise<T[]>;
696
699
  /**
@@ -708,15 +711,11 @@ declare abstract class EntityCommunicationService<T> {
708
711
  * @deprecated Use createOrUpdate(payload) instead.
709
712
  */
710
713
  createOperation(payload: Partial<T>): Promise<T>;
711
- query(filterConfig: FiltersConfig): Promise<IFilterQueryResponse<T>>;
712
714
  /**
713
- * @deprecated Use createOrUpdate instead.
714
- */
715
+ * @deprecated This was changed to use operation() method., refactor your code to use operation.
716
+ */
717
+ query(filterConfig: FiltersConfig): Promise<IFilterQueryResponse<T>>;
715
718
  update(id: string, update: any): Promise<T>;
716
- /**
717
- * @deprecated Use createOrUpdate or updateOne instead.
718
- */
719
- updateOneOperation(id: string, payload: any): Promise<T>;
720
719
  partialUpdate(id: string, partialUpdates: Partial<T>): Promise<T>;
721
720
  remove(id: string): Promise<void>;
722
721
  /**
@@ -725,8 +724,47 @@ declare abstract class EntityCommunicationService<T> {
725
724
  removeOperation(id: string): Promise<any>;
726
725
  clone(id: string, overrides?: Partial<T>): Promise<T>;
727
726
  getFixedQuery(): Record<string, any>;
727
+ /**
728
+ * Executes a single database operation through a flexible interface provided by the backend's `@dataclouder/nest-mongo` ecosystem.
729
+ * By leveraging this endpoint, clients can safely execute any common MongoDB operation by passing the appropriate configuration.
730
+ *
731
+ * @param params - The payload containing the operation details.
732
+ * @param params.action - The database action to perform. Valid options are:
733
+ * - `'findOne'`: Fetch the first document matching `query`.
734
+ * - `'find'`: Retrieve multiple documents matching `query` (supports `projection` and `options`).
735
+ * - `'create'`: Insert a new document utilizing `payload`.
736
+ * - `'updateOne'`: Modify the first document matching `query` using update operators in `payload`.
737
+ * - `'updateMany'`: Modify all documents matching `query` using `payload`.
738
+ * - `'deleteOne'`: Remove the first document matching `query`.
739
+ * - `'deleteMany'`: Remove all documents matching `query`.
740
+ * - `'aggregate'`: Run an aggregation pipeline provided in `payload` as an array.
741
+ * - `'clone'`: Create a copy of a document identified by `query`, overriding properties with `payload`.
742
+ * @param params.query - The MongoDB query used to select documents (e.g., `{ status: "active" }`).
743
+ * @param params.payload - The data for `create`, `updateOne`, `updateMany` (update operators), or the aggregation pipeline array.
744
+ * @param params.projection - Specifies the fields to return for `find` or `findOne` (e.g., `{ name: 1, email: 1 }`).
745
+ * @param params.options - Additional options for `find` operations like `limit`, `skip`, or `sort` (e.g., `{ limit: 10 }`).
746
+ *
747
+ * @example
748
+ * // Find multiple documents
749
+ * this.operation({
750
+ * action: 'find',
751
+ * query: { status: 'active' },
752
+ * projection: { name: 1 },
753
+ * options: { limit: 10, sort: { createdAt: -1 } }
754
+ * });
755
+ *
756
+ * @example
757
+ * // Update a single document
758
+ * this.operation({
759
+ * action: 'updateOne',
760
+ * query: { _id: '123' },
761
+ * payload: { $set: { status: 'inactive' } }
762
+ * });
763
+ *
764
+ * @returns A Promise resolving to the result of the database operation.
765
+ */
728
766
  operation(params: {
729
- action: 'findOne' | 'find' | 'create' | 'updateOne' | 'updateMany' | 'deleteOne' | 'deleteMany' | 'aggregate' | 'count';
767
+ action: 'findOne' | 'find' | 'create' | 'updateOne' | 'updateMany' | 'deleteOne' | 'deleteMany' | 'aggregate' | 'clone';
730
768
  query?: any;
731
769
  payload?: any;
732
770
  projection?: any;
@@ -813,6 +851,7 @@ declare abstract class EntityBaseFormComponent<T extends {
813
851
  abstract form: FormGroup;
814
852
  protected abstract entityCommunicationService: EntityCommunicationService<T>;
815
853
  protected abstract patchForm(entity: T): void;
854
+ private _stateSyncEffect;
816
855
  save(): Promise<T | undefined>;
817
856
  reload(): void;
818
857
  getDirtyValues(form: FormGroup | FormArray): {
@@ -827,6 +866,26 @@ declare abstract class EntityBaseFormComponent<T extends {
827
866
  static ɵdir: i0.ɵɵDirectiveDeclaration<EntityBaseFormComponent<any>, never, never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; "entityInput": { "alias": "entity"; "required": false; "isSignal": true; }; "useFakeSave": { "alias": "useFakeSave"; "required": false; "isSignal": true; }; }, { "fakeSaved": "fakeSaved"; }, never, never, true, never>;
828
867
  }
829
868
 
869
+ declare abstract class EntityBaseDetailComponent<T extends {
870
+ _id?: string;
871
+ }> {
872
+ protected route: ActivatedRoute;
873
+ toastService: _dataclouder_ngx_core.ToastAlertsAbstractService;
874
+ id: i0.InputSignal<string>;
875
+ entity: i0.WritableSignal<T>;
876
+ isLoading: i0.WritableSignal<boolean>;
877
+ private entityIdFromUrl;
878
+ entityId: i0.Signal<string>;
879
+ protected abstract entityCommunicationService: EntityCommunicationService<T>;
880
+ /** Called after the entity is successfully loaded. Override to react (e.g. load related data). */
881
+ protected onEntityLoaded(_entity: T): void;
882
+ private _loadEffect;
883
+ private loadEntity;
884
+ reload(): void;
885
+ static ɵfac: i0.ɵɵFactoryDeclaration<EntityBaseDetailComponent<any>, never>;
886
+ static ɵdir: i0.ɵɵDirectiveDeclaration<EntityBaseDetailComponent<any>, never, never, { "id": { "alias": "id"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
887
+ }
888
+
830
889
  declare enum EModelQuality {
831
890
  FAST = "fast",// Prioritize speed over intelligence like flash lite
832
891
  BALANCED = "balanced",// Equal balance like flash 2.5
@@ -1137,5 +1196,5 @@ declare const CharacterEventActions: {
1137
1196
  label: string;
1138
1197
  }[];
1139
1198
 
1140
- export { APP_CONFIG, AppConfigService, AudioNotificationService, AudioSpeed, AudioSpeedReverse, CharacterEventActions, ChatUserSettings, ConfirmComponent, ConfirmService, DCFilterBarComponent, DCProgressToastComponent, DcAuditableViewerComponent, DcExtensionsViewerComponent, DcLearnableFormComponent, DcLearnableViewerComponent, DcManageableFormComponent, DcManageableViewerComponent, DcReactionsViewerComponent, DcTagsFormComponent, EModelQuality, EmptyStateComponent, EntityBaseFormComponent, EntityBaseListComponent, EntityBaseListV2Component, EntityCommunicationService, FlagPipe, FormUtilsService, GetPathPipe, HTTP_CORE_CONFIG, HttpCoreService, IAIModel, LANGUAGES, LangDescTranslation, LoadingBarComponent, LoadingBarService, MobileService, ModelQualityOptions, MoodState, MoodStateOptions, OptionValue, PaginationBase, PromptService, QuickTableComponent, SUPPORTED_LANGUAGES, TOAST_ALERTS_TOKEN, ToastAlertsAbstractService, UiStateService, availibleFilters, extractJsonFromString, formatCamelCaseString, getLangDesc, getSupportedLanguageOptions, provideToastAlert, sortOptions, sortTypes };
1141
- export type { AppException, ConfirmOptions, DeleteHttpParams, DeletedData, FiltersConfig, GetHttpParams, HttpCoreConfig, HttpCoreError, IAppConfig, IAuditable, ICustomFilter, IExtensionable, IFilterQueryResponse, ILangTranslation, ILanguageData, ILearnable, IManageable, IReactable, LearnableForm, ListFilterBarOptions, MongoState, OnActionEvent, PColumn, PostHttpParams, PromptOptions, PutHttpParams, SortOption, ToastData };
1199
+ export { APP_CONFIG, AppConfigService, AudioNotificationService, AudioSpeed, AudioSpeedReverse, CharacterEventActions, ChatUserSettings, ConfirmComponent, ConfirmService, DCFilterBarComponent, DCProgressToastComponent, DcAuditableViewerComponent, DcExtensionsViewerComponent, DcLearnableFormComponent, DcLearnableViewerComponent, DcManageableFormComponent, DcManageableViewerComponent, DcReactionsViewerComponent, DcTagsFormComponent, EModelQuality, EmptyStateComponent, EntityBaseDetailComponent, EntityBaseFormComponent, EntityBaseListComponent, EntityBaseListV2Component, EntityCommunicationService, FlagPipe, FormUtilsService, GetPathPipe, HTTP_CORE_CONFIG, HttpCoreService, IAIModel, LANGUAGES, LangDescTranslation, LoadingBarComponent, LoadingBarService, MobileService, ModelQualityOptions, MoodState, MoodStateOptions, OptionValue, PaginationBase, PromptService, QuickTableComponent, SUPPORTED_LANGUAGES, TOAST_ALERTS_TOKEN, ToastAlertsAbstractService, UiStateService, availibleFilters, extractJsonFromString, formatCamelCaseString, getLangDesc, getSupportedLanguageOptions, provideToastAlert, sortOptions, sortTypes };
1200
+ export type { AppException, ConfirmOptions, DeleteHttpParams, DeletedData, EntityViewMode, FiltersConfig, GetHttpParams, HttpCoreConfig, HttpCoreError, IAppConfig, IAuditable, ICustomFilter, IExtensionable, IFilterQueryResponse, ILangTranslation, ILanguageData, ILearnable, IManageable, IReactable, LearnableForm, ListFilterBarOptions, MongoState, OnActionEvent, PColumn, PostHttpParams, PromptOptions, PutHttpParams, SortOption, ToastData };