@common-stack/store-mongo 8.2.5-alpha.11 → 8.2.5-alpha.15

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.
@@ -1,5 +1,9 @@
1
1
  import type { Document, FilterQuery, Model, UpdateQuery } from 'mongoose';
2
2
  import type { GetAllArgs } from './getAllArgs';
3
+ /**
4
+ * @deprecated Use IBaseMongoRepository from 'common/server' instead. This interface will be removed in a future version.
5
+ * Import from the template-generated interfaces in your common package.
6
+ */
3
7
  export interface IBaseRepository<T, D = Document<T>> {
4
8
  model: Model<D>;
5
9
  count(conditions?: FilterQuery<D>): Promise<number>;
@@ -1,5 +1,9 @@
1
1
  import type { FilterQuery, Document } from 'mongoose';
2
2
  import type { GetAllArgs } from './getAllArgs';
3
+ /**
4
+ * @deprecated Use IBaseService from 'common/server' instead. This interface will be removed in a future version.
5
+ * Import from the template-generated interfaces in your common package.
6
+ */
3
7
  export interface IBaseService<T, C = Omit<T, 'id'>, U = C> {
4
8
  count(conditions?: FilterQuery<Document<T>>): Promise<number>;
5
9
  get(id: string): Promise<T>;
@@ -1,10 +1,16 @@
1
1
  import DataLoader from 'dataloader';
2
2
  import { IBaseService } from './base-service';
3
+ /**
4
+ * @deprecated Use DataLoaderOptions from 'common/server' instead. This type will be removed in a future version.
5
+ */
3
6
  export type DataLoaderOptions<T> = Parameters<IBaseService<T>['getAll']>[0] & {
4
7
  id: string;
5
8
  searchKey: keyof T;
6
9
  comparator?: (source: Omit<DataLoaderOptions<T>, 'comparator'>, target: T) => boolean;
7
10
  };
11
+ /**
12
+ * @deprecated Use IDataLoader from 'common/server' instead. This type will be removed in a future version.
13
+ */
8
14
  export type IDataLoader<T> = DataLoader<string, T> & {
9
15
  withOptions: DataLoader<DataLoaderOptions<T>, T[]>;
10
16
  };
@@ -14,7 +14,7 @@ export declare class BaseService2<SchemaType, C = CreateType<SchemaType>, U = Up
14
14
  getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]>;
15
15
  create(data: C): Promise<AsDomainType<SchemaType>>;
16
16
  bulkCreate(data: C[]): Promise<AsDomainType<SchemaType>[]>;
17
- update(id: string, data: Partial<U>, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
17
+ update(id: string, data: U, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
18
18
  insert(data: (C | U) & {
19
19
  id?: string;
20
20
  }, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
@@ -1 +1 @@
1
- {"version":3,"file":"BaseService.js","sources":["../../src/services/BaseService.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable import/no-unresolved */\n/* eslint-disable no-useless-catch */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable no-empty-function */\nimport type { FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport type {\n GetAllArgs,\n IBaseMongoRepository,\n IBaseService,\n AsDomainType,\n CreateType,\n UpdateType,\n} from 'common/server';\n\n@injectable()\nexport class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>>\n implements IBaseService<SchemaType, C, U>\n{\n constructor(protected repository: IBaseMongoRepository<SchemaType>) {}\n\n async getAllWithCount(\n options: GetAllArgs<SchemaType>,\n ): Promise<{ data: AsDomainType<SchemaType>[]; totalCount: number }> {\n return this.repository.getAllWithCount(options);\n }\n\n count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions } as FilterQuery<SchemaType>);\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.repository.get({ name } as any);\n }\n\n getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<AsDomainType<SchemaType>> {\n return this.repository.create(data);\n }\n\n bulkCreate(data: C[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkCreate(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<AsDomainType<SchemaType>> {\n return this.repository.update({ id } as any, data, { overwrite });\n }\n\n async insert(data: (C | U) & { id?: string }, overwrite = true): Promise<AsDomainType<SchemaType>> {\n const { id, ...rest } = data as (C | U) & { id?: string };\n\n if (id) {\n try {\n const existing = await this.repository.get({ id } as any);\n if (existing) {\n return this.update(id, rest as any, overwrite);\n }\n } catch (error) {\n // If not found, continue to create\n }\n }\n\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<SchemaType>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id } as any);\n }\n return this.repository.delete(id);\n }\n\n bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.bulkDelete(criteria);\n }\n}\n"],"names":[],"mappings":"6EAkBa,IAAA,YAAY,GAAlB,MAAM,YAAY,CAAA;AAGC,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA4C,EAAA;QAA5C,IAAU,CAAA,UAAA,GAAV,UAAU,CAAkC;KAAI;IAEtE,MAAM,eAAe,CACjB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KACnD;AAED,IAAA,KAAK,CAAC,UAAoC,EAAA;QACtC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,UAA4C,EAAA;AAC5C,QAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAA6B,CAAC,CAAC;SAC7E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AAO,KAAK,EAAE;;aAEf;SACJ;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/C;EACJ;AAzEY,YAAY,GAAA,UAAA,CAAA;AADxB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,YAAY,CAyExB"}
1
+ {"version":3,"file":"BaseService.js","sources":["../../src/services/BaseService.ts"],"sourcesContent":["/* eslint-disable import/no-extraneous-dependencies */\n/* eslint-disable import/no-unresolved */\n/* eslint-disable no-useless-catch */\n/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-useless-constructor */\n/* eslint-disable no-empty-function */\nimport type { FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport type {\n GetAllArgs,\n IBaseMongoRepository,\n IBaseService,\n AsDomainType,\n CreateType,\n UpdateType,\n} from 'common/server';\n\n@injectable()\nexport class BaseService2<SchemaType, C = CreateType<SchemaType>, U = UpdateType<SchemaType>>\n implements IBaseService<SchemaType, C, U>\n{\n constructor(protected repository: IBaseMongoRepository<SchemaType>) {}\n\n async getAllWithCount(\n options: GetAllArgs<SchemaType>,\n ): Promise<{ data: AsDomainType<SchemaType>[]; totalCount: number }> {\n return this.repository.getAllWithCount(options);\n }\n\n count(conditions?: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<SchemaType>): Promise<AsDomainType<SchemaType> | null> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions } as FilterQuery<SchemaType>);\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<AsDomainType<SchemaType> | null> {\n return this.repository.get({ name } as any);\n }\n\n getAll(options: GetAllArgs<SchemaType>): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<AsDomainType<SchemaType>> {\n return this.repository.create(data);\n }\n\n bulkCreate(data: C[]): Promise<AsDomainType<SchemaType>[]> {\n return this.repository.bulkCreate(data);\n }\n\n async update(id: string, data: U, overwrite = false): Promise<AsDomainType<SchemaType>> {\n return this.repository.update({ id } as any, data, { overwrite });\n }\n\n async insert(data: (C | U) & { id?: string }, overwrite = true): Promise<AsDomainType<SchemaType>> {\n const { id, ...rest } = data as (C | U) & { id?: string };\n\n if (id) {\n try {\n const existing = await this.repository.get({ id } as any);\n if (existing) {\n return this.update(id, rest as any, overwrite);\n }\n } catch (error) {\n // If not found, continue to create\n }\n }\n\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<SchemaType>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id } as any);\n }\n return this.repository.delete(id);\n }\n\n bulkDelete(criteria: FilterQuery<SchemaType>): Promise<number> {\n return this.repository.bulkDelete(criteria);\n }\n}\n"],"names":[],"mappings":"6EAkBa,IAAA,YAAY,GAAlB,MAAM,YAAY,CAAA;AAGC,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA4C,EAAA;QAA5C,IAAU,CAAA,UAAA,GAAV,UAAU,CAAkC;KAAI;IAEtE,MAAM,eAAe,CACjB,OAA+B,EAAA;QAE/B,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KACnD;AAED,IAAA,KAAK,CAAC,UAAoC,EAAA;QACtC,OAAO,IAAI,CA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,YAAA,IAAI;AACA,gBAAA,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;gBAC1D,IAAI,QAAQ,EAAE;oBACV,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAW,EAAE,SAAS,CAAC,CAAC;iBAClD;aACJ;YAAC,OAAO,KAAK,EAAE;;aAEf;SACJ;AAED,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAS,CAAC,CAAC;KACjC;AAED,IAAA,MAAM,CAAC,EAAoC,EAAA;AACvC,QAAA,IAAI,OAAO,EAAE,KAAK,QAAQ,EAAE;YACxB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAS,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;AAED,IAAA,UAAU,CAAC,QAAiC,EAAA;QACxC,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;KAC/C;EACJ;AAzEY,YAAY,GAAA,UAAA,CAAA;AADxB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,YAAY,CAyExB"}
@@ -5,6 +5,9 @@ import type { GetAllArgs } from '../interfaces';
5
5
  import type { IBaseService } from '../interfaces/index.old';
6
6
  type MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;
7
7
  type MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;
8
+ /**
9
+ * @deprecated Use BaseProxyService2 instead. This class will be removed in a future version.
10
+ */
8
11
  export declare abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {
9
12
  private readonly broker;
10
13
  protected abstract logger?: CdmLogger.ILogger;
@@ -1,4 +1,7 @@
1
- import {__decorate,__param,__metadata}from'tslib';import {injectable,inject,optional}from'inversify';import {CommonType}from'@common-stack/core';import {BaseServiceCommands}from'common';let BaseProxyService = class BaseProxyService {
1
+ import {__decorate,__param,__metadata}from'tslib';import {injectable,inject,optional}from'inversify';import {CommonType}from'@common-stack/core';import {BaseServiceCommands}from'common';/**
2
+ * @deprecated Use BaseProxyService2 instead. This class will be removed in a future version.
3
+ */
4
+ let BaseProxyService = class BaseProxyService {
2
5
  broker;
3
6
  constructor(broker, logger) {
4
7
  this.broker = broker;
@@ -1 +1 @@
1
- {"version":3,"file":"base-proxy-service.js","sources":["../../src/services/base-proxy-service.ts"],"sourcesContent":["import { inject, injectable, optional } from 'inversify';\nimport type { ServiceBroker } from 'moleculer';\nimport type { FilterQuery } from 'mongoose';\nimport type { CdmLogger } from '@cdm-logger/core';\nimport { CommonType } from '@common-stack/core';\nimport { BaseServiceCommands } from 'common';\nimport type { GetAllArgs } from '../interfaces';\nimport type { IBaseService } from '../interfaces/index.old';\n\ntype MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;\ntype MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;\n\n@injectable()\nexport abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {\n protected abstract logger?: CdmLogger.ILogger;\n\n protected abstract topic;\n\n constructor(\n @inject(CommonType.MOLECULER_BROKER)\n private readonly broker: ServiceBroker,\n @inject(CommonType.LOGGER)\n @optional()\n logger: CdmLogger.ILogger,\n ) {}\n\n getByName(name: string): Promise<T> {\n return this.callAction(BaseServiceCommands.GetByName, { name });\n }\n\n bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'> {\n return this.callAction<T[], { data: C[] }>(BaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'> {\n return this.callAction(BaseServiceCommands.Count, { criteria });\n }\n\n create(data: C): MethodResponse<T, C, U, 'create'> {\n return this.callAction(BaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'> {\n return this.callAction(BaseServiceCommands.Delete, { id });\n }\n\n get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'> {\n return this.callAction(BaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'> {\n return this.callAction(BaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.callAction(BaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'> {\n return this.callAction(BaseServiceCommands.GetAllWithCount, options);\n }\n\n insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'> {\n return this.callAction(BaseServiceCommands.Insert, { data, overwrite });\n }\n\n update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'> {\n return this.callAction<T>(BaseServiceCommands.Update, { id, data, overwrite });\n }\n\n protected async callAction<T, P = unknown>(command: string, params?: P): Promise<T> {\n return this.broker.call<T, P>(`${this.topic}.${command}`, params);\n }\n}\n"],"names":[],"mappings":"0LAasB,IAAA,gBAAgB,GAA/B,MAAe,gBAAgB,CAAA;AAOb,IAAA,MAAA,CAAA;IAFrB,WAEqB,CAAA,MAAqB,EAGtC,MAAyB,EAAA;QAHR,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;KAItC;AAEJ,IAAA,SAAS,CAAC,IAAY,EAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACnE;AAED,IAAA,UAAU,CAAC,IAAS,EAAA;AAChB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAqB,mBAAmB,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;KACxF;AAED,IAAA,KAAK,CAAC,QAAgC,EAAA;AAClC,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,KAAK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iB,OAAe,EAAE,MAAU,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,CAAG,EAAA,IAAI,CAAC,KAAK,IAAI,OAAO,CAAA,CAAE,EAAE,MAAM,CAAC,CAAC;KACrE;EACJ;AA5DqB,gBAAgB,GAAA,UAAA,CAAA;AADrC,IAAA,UAAU,EAAE;AAOJ,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAEnC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzB,OAAA,CAAA,CAAA,EAAA,QAAQ,EAAE,CAAA;;AATG,CAAA,EAAA,gBAAgB,CA4DrC"}
1
+ {"version":3,"file":"base-proxy-service.js","sources":["../../src/services/base-proxy-service.ts"],"sourcesContent":["import { inject, injectable, optional } from 'inversify';\nimport type { ServiceBroker } from 'moleculer';\nimport type { FilterQuery } from 'mongoose';\nimport type { CdmLogger } from '@cdm-logger/core';\nimport { CommonType } from '@common-stack/core';\nimport { BaseServiceCommands } from 'common';\nimport type { GetAllArgs } from '../interfaces';\nimport type { IBaseService } from '../interfaces/index.old';\n\ntype MethodsNames<T, C, U> = keyof IBaseService<T, C, U>;\ntype MethodResponse<T, C, U, M extends MethodsNames<T, C, U>> = ReturnType<IBaseService<T, C, U>[M]>;\n\n/**\n * @deprecated Use BaseProxyService2 instead. This class will be removed in a future version.\n */\n@injectable()\nexport abstract class BaseProxyService<T, C = T, U = T> implements IBaseService<T, C, U> {\n protected abstract logger?: CdmLogger.ILogger;\n\n protected abstract topic;\n\n constructor(\n @inject(CommonType.MOLECULER_BROKER)\n private readonly broker: ServiceBroker,\n @inject(CommonType.LOGGER)\n @optional()\n logger: CdmLogger.ILogger,\n ) {}\n\n getByName(name: string): Promise<T> {\n return this.callAction(BaseServiceCommands.GetByName, { name });\n }\n\n bulkCreate(data: C[]): MethodResponse<T, C, U, 'bulkCreate'> {\n return this.callAction<T[], { data: C[] }>(BaseServiceCommands.BulkCreate, { data });\n }\n\n count(criteria?: FilterQuery<Document>): MethodResponse<T, C, U, 'count'> {\n return this.callAction(BaseServiceCommands.Count, { criteria });\n }\n\n create(data: C): MethodResponse<T, C, U, 'create'> {\n return this.callAction(BaseServiceCommands.Create, { data });\n }\n\n delete(id: string | FilterQuery<Document>): MethodResponse<T, C, U, 'delete'> {\n return this.callAction(BaseServiceCommands.Delete, { id });\n }\n\n get(id?: string | FilterQuery<Document>): MethodResponse<T, C, U, 'get'> {\n return this.callAction(BaseServiceCommands.Get, { id });\n }\n\n getAll(options?: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAll'> {\n return this.callAction(BaseServiceCommands.GetAll, options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.callAction(BaseServiceCommands.GetByIds, { ids });\n }\n\n getAllWithCount(options: GetAllArgs<Document>): MethodResponse<T, C, U, 'getAllWithCount'> {\n return this.callAction(BaseServiceCommands.GetAllWithCount, options);\n }\n\n insert(data: C | U, overwrite?: boolean): MethodResponse<T, C, U, 'insert'> {\n return this.callAction(BaseServiceCommands.Insert, { data, overwrite });\n }\n\n update(id: string, data: U, overwrite?: boolean): MethodResponse<T, C, U, 'update'> {\n return this.callAction<T>(BaseServiceCommands.Update, { id, data, overwrite });\n }\n\n protected async callAction<T, P = unknown>(command: string, params?: P): Promise<T> {\n return this.broker.call<T, P>(`${this.topic}.${command}`, params);\n }\n}\n"],"names":[],"mappings":"0LAYA;;AAEG;AAEmB,IAAA,gBAAgB,GAA/B,MAAe,gBAAgB,CAAA;AAOb,IAAA,MAAA,CAAA;IAFrB,WAEqB,CAAA,MAAqB,EAGtC,MAAyB,EAAA;QAHR,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;KAItC;AAEJ,IAAA,SAAS,CAAC,IAAY,EAAA;AAClB,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,SAAS,EAAE,EAAE,IA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EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAC3E;AAED,IAAA,MAAM,CAAC,EAAU,EAAE,IAAO,EAAE,SAAmB,EAAA;AAC3C,QAAA,OAAO,IAAI,CAAC,UAAU,CAAI,mBAAmB,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;KAClF;AAES,IAAA,MAAM,UAAU,CAAiB,OAAe,EAAE,MAAU,EAAA;AAClE,QAAA,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAO,CAAG,EAAA,IAAI,CAAC,KAAK,IAAI,OAAO,CAAA,CAAE,EAAE,MAAM,CAAC,CAAC;KACrE;EACJ;AA5DqB,gBAAgB,GAAA,UAAA,CAAA;AADrC,IAAA,UAAU,EAAE;AAOJ,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AAEnC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IACzB,OAAA,CAAA,CAAA,EAAA,QAAQ,EAAE,CAAA;;AATG,CAAA,EAAA,gBAAgB,CA4DrC"}
@@ -1,6 +1,9 @@
1
1
  import type { Document, FilterQuery } from 'mongoose';
2
2
  import type { GetAllArgs } from '../interfaces';
3
3
  import type { IBaseRepository, IBaseService } from '../interfaces/index.old';
4
+ /**
5
+ * @deprecated Use BaseService2 instead. This class will be removed in a future version.
6
+ */
4
7
  export declare class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {
5
8
  protected repository: IBaseRepository<T>;
6
9
  constructor(repository: IBaseRepository<T>);
@@ -15,7 +18,7 @@ export declare class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseSe
15
18
  getByIds(ids: string[]): Promise<T[]>;
16
19
  create(data: C): Promise<T>;
17
20
  bulkCreate(data: C[]): Promise<T[]>;
18
- update(id: string, data: Partial<U>, overwrite?: boolean): Promise<T>;
21
+ update(id: string, data: U, overwrite?: boolean): Promise<T>;
19
22
  insert(data: (C | U) & {
20
23
  id?: string;
21
24
  }, overwrite?: boolean): Promise<T>;
@@ -1,4 +1,7 @@
1
- import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';let BaseService = class BaseService {
1
+ import {__decorate,__metadata}from'tslib';import {injectable}from'inversify';/**
2
+ * @deprecated Use BaseService2 instead. This class will be removed in a future version.
3
+ */
4
+ let BaseService = class BaseService {
2
5
  repository;
3
6
  constructor(repository) {
4
7
  this.repository = repository;
@@ -1 +1 @@
1
- {"version":3,"file":"base-service.js","sources":["../../src/services/base-service.ts"],"sourcesContent":["import type { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport type { GetAllArgs } from '../interfaces';\nimport type { IBaseRepository, IBaseService } from '../interfaces/index.old';\n\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<Document<T>>): Promise<T> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions });\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: Partial<U>, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<Document<T>>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id });\n }\n return this.repository.delete(id);\n }\n}\n"],"names":[],"mappings":"6EAMa,IAAA,WAAW,GAAjB,MAAM,WAAW,CAAA;AACE,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA8B,EAAA;QAA9B,IAAU,CAAA,UAAA,GAAV,UAAU,CAAoB;AAChD,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;IAED,MAAM,eAAe,CAAC,OAAgC,EAAA;QAClD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO;YACH,UAAU;YACV,IAAI;SACP,CAAC;KACL;AAED,IAAA,KAAK,CAAC,UAAqC,EAAA;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,UAA6C,EAAA;AAC7C,QAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1C;AAED,IAAA,SAAS,CAAC,IAAY,EAAA;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACxC;AAED,IAAA,M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AAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrC;EACJ;AAlEY,WAAW,GAAA,UAAA,CAAA;AADvB,IAAA,UAAU,EAAE;;AACA,CAAA,EAAA,WAAW,CAkEvB"}
1
+ {"version":3,"file":"base-service.js","sources":["../../src/services/base-service.ts"],"sourcesContent":["import type { Document, FilterQuery } from 'mongoose';\nimport { injectable } from 'inversify';\nimport type { GetAllArgs } from '../interfaces';\nimport type { IBaseRepository, IBaseService } from '../interfaces/index.old';\n\n/**\n * @deprecated Use BaseService2 instead. This class will be removed in a future version.\n */\n@injectable()\nexport class BaseService<T, C = Omit<T, 'id'>, U = C> implements IBaseService<T, C, U> {\n constructor(protected repository: IBaseRepository<T>) {\n this.repository = repository;\n }\n\n async getAllWithCount(options: GetAllArgs<Document<T>>): Promise<{ data: T[]; totalCount: number }> {\n const totalCount = await this.count(options.criteria);\n const data = await this.getAll(options);\n return {\n totalCount,\n data,\n };\n }\n\n count(conditions?: FilterQuery<Document<T>>): Promise<number> {\n return this.repository.count(conditions);\n }\n\n get(conditions: string | FilterQuery<Document<T>>): Promise<T> {\n if (typeof conditions === 'string') {\n return this.repository.get({ id: conditions });\n }\n return this.repository.get(conditions);\n }\n\n getByName(name: string): Promise<T> {\n return this.repository.get({ name });\n }\n\n getAll(options: GetAllArgs<Document<T>>): Promise<T[]> {\n return this.repository.getAll(options);\n }\n\n getByIds(ids: string[]): Promise<T[]> {\n return this.repository.bulkGet(ids);\n }\n\n create(data: C): Promise<T> {\n return this.repository.create<C>(data);\n }\n\n bulkCreate(data: C[]): Promise<T[]> {\n return this.repository.bulkCreate<C>(data);\n }\n\n async update(id: string, data: U, overwrite = false): Promise<T> {\n return this.repository.update<U>({ id }, data, { overwrite });\n }\n\n insert(data: (C | U) & { id?: string }, overwrite = true): Promise<T> {\n const { id, ...rest } = data;\n if (id) {\n const existing = this.repository.get({ id });\n if (existing) {\n return this.update(id, rest as U, overwrite);\n }\n }\n return this.create(rest as C);\n }\n\n delete(id: string | FilterQuery<Document<T>>): Promise<boolean> {\n if (typeof id === 'string') {\n return this.repository.delete({ id });\n }\n return this.repository.delete(id);\n }\n}\n"],"names":[],"mappings":"6EAKA;;AAEG;AAEU,IAAA,WAAW,GAAjB,MAAM,WAAW,CAAA;AACE,IAAA,UAAA,CAAA;AAAtB,IAAA,WAAA,CAAsB,UAA8B,EAAA;QAA9B,IAAU,CAAA,UAAA,GAAV,UAAU,CAAoB;AAChD,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;KAChC;IAED,MAAM,eAAe,CAAC,OAAgC,EAAA;QAClD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO;YACH,UAAU;YACV,IAAI;SACP,CAAC;KACL;AAED,IAAA,KAAK,CAAC,UAAqC,EAAA;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;KAC5C;AAED,IAAA,GAAG,CAAC,UAA6C,EAAA;AAC7C,QAAA,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;AAChC,YAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;SAClD;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC1C;AAED,IAAA,SAAS,CAAC,IAAY,EAAA;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;KACxC;AAED,IAAA,MAAM,CAAC,OAAgC,EAAA;QACnC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;KAC1C;AAED,IAAA,QAAQ,CAAC,GAAa,EAAA;QAClB,OAAO,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AkEvB"}
@@ -4,6 +4,9 @@ import type { Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'm
4
4
  import type { GetAllArgs, IMongoOptions } from '../../interfaces';
5
5
  import { IBaseRepository } from 'src/interfaces/index.old';
6
6
  type Connection = mongoose.Connection;
7
+ /**
8
+ * @deprecated Use BaseMongoRepository instead. This class will be removed in a future version.
9
+ */
7
10
  export declare class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {
8
11
  private modelFunc;
9
12
  private options;
@@ -1,5 +1,8 @@
1
1
  import {__decorate,__param,__metadata}from'tslib';import {isObject}from'lodash-es';import mongoose__default from'mongoose';import {injectable,unmanaged}from'inversify';import {PAGINATION_OPTIONS}from'../../interfaces/getAllArgs.js';var BaseRepository_1;
2
2
  const { Types } = mongoose__default;
3
+ /**
4
+ * @deprecated Use BaseMongoRepository instead. This class will be removed in a future version.
5
+ */
3
6
  let BaseRepository = BaseRepository_1 = class BaseRepository {
4
7
  modelFunc;
5
8
  options;
@@ -1 +1 @@
1
- {"version":3,"file":"base-repository.js","sources":["../../../src/store/repositories/base-repository.ts"],"sourcesContent":["import { isObject } from 'lodash-es';\nimport type { CdmLogger } from '@cdm-logger/core';\nimport mongoose from 'mongoose';\nimport type { Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport type { GetAllArgs, IMongoOptions } from '../../interfaces';\nimport { PAGINATION_OPTIONS } from '../../interfaces';\nimport { IBaseRepository } from 'src/interfaces/index.old';\n\nconst { Types } = mongoose;\ntype Connection = mongoose.Connection;\n\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: CdmLogger.ILogger;\n\n model: Model<D>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<D>,\n @unmanaged()\n db: Connection,\n @unmanaged()\n logger: CdmLogger.ILogger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db);\n this.options = options;\n this.logger = logger.child({ className: BaseRepository.name });\n }\n\n private computeSort(sort: GetAllArgs<D>['sort']): Record<string, 1 | -1> | null {\n if (isObject(sort)) {\n return { [sort?.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 };\n }\n return null;\n }\n\n preparePipeLine(options: GetAllArgs<D>): PipelineStage[] {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const mappedCriteria = Object.entries(criteria || {}).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: Types.ObjectId.isValid(value) ? new Types.ObjectId(value) : value,\n }),\n { id: undefined },\n );\n const { id, ...rest } = mappedCriteria;\n const projectedFields = selectedFields?.split(' ').reduce(\n (acc, key) => ({\n ...acc,\n [key]: 1,\n }),\n {},\n );\n return [\n { $match: Object.assign({}, rest, id ? { _id: id } : {}) },\n ...(sort ? [{ $sort: this.computeSort(sort) }] : []),\n ...(selectedFields?.length\n ? [\n {\n $project: projectedFields,\n },\n ]\n : []),\n { $skip: skip || PAGINATION_OPTIONS.skip },\n { $limit: limit || PAGINATION_OPTIONS.limit },\n { $addFields: { id: '$_id' } },\n { $project: { _id: 0 } },\n ];\n }\n\n // public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n // try {\n // return this.model.aggregate(this.preparePipeLine(options));\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const { id, ...rest } = criteria || { id: undefined };\n const sortBy = isObject(sort) ? { [sort?.key]: sort.value } : { createdAt: 1 };\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .sort(sortBy as never)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);\n throw e;\n }\n }\n\n public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[]; totalCount: number }> {\n const data = await this.getAll(options);\n const totalCount = await this.count(options.criteria);\n return { totalCount, data };\n }\n\n // public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[], totalCount: number }> {\n // try {\n // const pipeline: PipelineStage[] = this.preparePipeLine(options);\n // pipeline.push({\n // $facet: {\n // data: [{\n // $group: {\n // _id: null,\n // items: { $push: '$$ROOT' }\n // }\n // }],\n // count: [{ $count: 'count' }],\n // },\n // })\n // const result = await this.model.aggregate(pipeline);\n // const data = result[0]?.data[0]?.items || [];\n // const totalCount = result[0]?.count[0]?.count || 0;\n // return { data, totalCount };\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n // eslint-disable-next-line class-methods-use-this\n private mapConditions(conditions: FilterQuery<D>): FilterQuery<D> {\n const { id: _id, ...remaining } = conditions;\n return {\n ...(_id ? { _id } : {}),\n ...remaining,\n };\n }\n\n public async count(conditions?: FilterQuery<D>): Promise<number> {\n return this.model.count(conditions).exec();\n }\n\n public async get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[]): Promise<T[]> {\n try {\n const results = await this.model.find().setOptions({ batchSize: 100 }).where('_id').in(ids).exec();\n return results.map((i) => i.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);\n throw e;\n }\n }\n\n public async find(conditions: Partial<FilterQuery<D>>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async create<I>(data: I): Promise<T> {\n try {\n const response = await this.model.create(data);\n return response.toObject() as T;\n } catch (e) {\n this.logger.error(\n e,\n 'Unable to create Model with data ${JSON.stringify(data)} due to error [%s]',\n e.message,\n );\n throw e;\n }\n }\n\n public async bulkCreate<I>(data: I[]): Promise<T[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n return response as unknown as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);\n }\n }\n\n public async upsert<I>(conditions: FilterQuery<D>, update: I, options?: Record<string, unknown>): Promise<T> {\n return this.update<I>(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async bulkUpdate<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T[]> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const res = await this.model.updateMany(processedCriteria, update);\n if (res) {\n const response = await this.model.find(processedCriteria).exec();\n return response.map((i) => i?.toObject()) as T[];\n } else {\n this.logger.error('Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw new Error('Unable to do bulk update');\n }\n } catch (e) {\n this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async update<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n if (id) {\n return (await this.model\n .findByIdAndUpdate(id, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n }\n return (await this.model\n .findOneAndUpdate(processedCriteria, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n } catch (e) {\n this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<D>): Promise<boolean> {\n try {\n let deleted;\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(this.mapConditions(criteria));\n }\n return !!deleted;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkDelete(criteria: FilterQuery<D>): Promise<number> {\n try {\n const deleted = await this.model.deleteMany(this.mapConditions(criteria));\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n}\n"],"names":["mongoose"],"mappings":";AASA,MAAM,EAAE,KAAK,EAAE,GAAGA,iBAAQ,CAAC;AAId,IAAA,cAAc,GAApB,gBAAA,GAAA,MAAM,cAAc,CAAA;AASX,IAAA,SAAA,CAAA;AARJ,IAAA,OAAO,CAAgB;AAErB,IAAA,MAAM,CAAoB;AAEpC,IAAA,KAAK,CAAW;AAEhB,IAAA,WAAA,CAEY,SAAuC,EAE/C,EAAc,EAEd,MAAyB,EAEzB,OAAuB,EAAA;QANf,IAAS,CAAA,SAAA,GAAT,SAAS,CAA8B;AAQ/C,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,CAAC;AAC3B,QAAA,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACvB,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,gBAAc,CAAC,IAAI,EAAE,CAAC,CAAC;KAClE;AAEO,IAAA,WAAW,CAAC,IAA2B,EAAA;AAC3C,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE;YAChB,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,GAAG,CAAC,GA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,EAAE,CAAA;;AAdP,CAAA,EAAA,cAAc,CA+Q1B"}
1
+ {"version":3,"file":"base-repository.js","sources":["../../../src/store/repositories/base-repository.ts"],"sourcesContent":["import { isObject } from 'lodash-es';\nimport type { CdmLogger } from '@cdm-logger/core';\nimport mongoose from 'mongoose';\nimport type { Document, FilterQuery, Model, PipelineStage, UpdateQuery } from 'mongoose';\nimport { injectable, unmanaged } from 'inversify';\nimport type { GetAllArgs, IMongoOptions } from '../../interfaces';\nimport { PAGINATION_OPTIONS } from '../../interfaces';\nimport { IBaseRepository } from 'src/interfaces/index.old';\n\nconst { Types } = mongoose;\ntype Connection = mongoose.Connection;\n\n/**\n * @deprecated Use BaseMongoRepository instead. This class will be removed in a future version.\n */\n@injectable()\nexport class BaseRepository<T, D = Document<T>> implements IBaseRepository<T, D> {\n private options: IMongoOptions;\n\n protected logger: CdmLogger.ILogger;\n\n model: Model<D>;\n\n constructor(\n @unmanaged()\n private modelFunc: (db: Connection) => Model<D>,\n @unmanaged()\n db: Connection,\n @unmanaged()\n logger: CdmLogger.ILogger,\n @unmanaged()\n options?: IMongoOptions,\n ) {\n this.model = modelFunc(db);\n this.options = options;\n this.logger = logger.child({ className: BaseRepository.name });\n }\n\n private computeSort(sort: GetAllArgs<D>['sort']): Record<string, 1 | -1> | null {\n if (isObject(sort)) {\n return { [sort?.key]: sort.value.toLowerCase() === 'asc' ? 1 : -1 };\n }\n return null;\n }\n\n preparePipeLine(options: GetAllArgs<D>): PipelineStage[] {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const mappedCriteria = Object.entries(criteria || {}).reduce(\n (acc, [key, value]) => ({\n ...acc,\n [key]: Types.ObjectId.isValid(value) ? new Types.ObjectId(value) : value,\n }),\n { id: undefined },\n );\n const { id, ...rest } = mappedCriteria;\n const projectedFields = selectedFields?.split(' ').reduce(\n (acc, key) => ({\n ...acc,\n [key]: 1,\n }),\n {},\n );\n return [\n { $match: Object.assign({}, rest, id ? { _id: id } : {}) },\n ...(sort ? [{ $sort: this.computeSort(sort) }] : []),\n ...(selectedFields?.length\n ? [\n {\n $project: projectedFields,\n },\n ]\n : []),\n { $skip: skip || PAGINATION_OPTIONS.skip },\n { $limit: limit || PAGINATION_OPTIONS.limit },\n { $addFields: { id: '$_id' } },\n { $project: { _id: 0 } },\n ];\n }\n\n // public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n // try {\n // return this.model.aggregate(this.preparePipeLine(options));\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n public async getAll(options: GetAllArgs<D>): Promise<T[]> {\n try {\n const { criteria, selectedFields, sort, limit, skip } = options;\n // map id to mongoose _id\n const { id, ...rest } = criteria || { id: undefined };\n const sortBy = isObject(sort) ? { [sort?.key]: sort.value } : { createdAt: 1 };\n const response = await this.model\n .find({ ...rest, ...(id ? { _id: id } : {}) }, selectedFields)\n .sort(sortBy as never)\n .limit(limit || PAGINATION_OPTIONS.limit)\n .skip(skip || PAGINATION_OPTIONS.skip)\n .exec();\n return response.map((i) => i?.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', options);\n throw e;\n }\n }\n\n public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[]; totalCount: number }> {\n const data = await this.getAll(options);\n const totalCount = await this.count(options.criteria);\n return { totalCount, data };\n }\n\n // public async getAllWithCount(options: GetAllArgs<D>): Promise<{ data: T[], totalCount: number }> {\n // try {\n // const pipeline: PipelineStage[] = this.preparePipeLine(options);\n // pipeline.push({\n // $facet: {\n // data: [{\n // $group: {\n // _id: null,\n // items: { $push: '$$ROOT' }\n // }\n // }],\n // count: [{ $count: 'count' }],\n // },\n // })\n // const result = await this.model.aggregate(pipeline);\n // const data = result[0]?.data[0]?.items || [];\n // const totalCount = result[0]?.count[0]?.count || 0;\n // return { data, totalCount };\n // } catch (e) {\n // this.logger.error(e, 'Unable to retrieve Model with options ${JSON.stringify(options)}`);\n // throw e;\n // }\n // }\n\n // eslint-disable-next-line class-methods-use-this\n private mapConditions(conditions: FilterQuery<D>): FilterQuery<D> {\n const { id: _id, ...remaining } = conditions;\n return {\n ...(_id ? { _id } : {}),\n ...remaining,\n };\n }\n\n public async count(conditions?: FilterQuery<D>): Promise<number> {\n return this.model.count(conditions).exec();\n }\n\n public async get(conditions?: FilterQuery<D>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(this.mapConditions(conditions), selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async bulkGet(ids: string[]): Promise<T[]> {\n try {\n const results = await this.model.find().setOptions({ batchSize: 100 }).where('_id').in(ids).exec();\n return results.map((i) => i.toObject()) as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', ids);\n throw e;\n }\n }\n\n public async find(conditions: Partial<FilterQuery<D>>, selectedFields?: string): Promise<T> {\n try {\n const response = await this.model.findOne(conditions, selectedFields).exec();\n return response?.toObject() as T;\n } catch (e) {\n this.logger.error(e, 'Unable to retrieve Model with criteria [%j]', conditions);\n throw e;\n }\n }\n\n public async create<I>(data: I): Promise<T> {\n try {\n const response = await this.model.create(data);\n return response.toObject() as T;\n } catch (e) {\n this.logger.error(\n e,\n 'Unable to create Model with data ${JSON.stringify(data)} due to error [%s]',\n e.message,\n );\n throw e;\n }\n }\n\n public async bulkCreate<I>(data: I[]): Promise<T[]> {\n try {\n const response = await this.model.insertMany(data, {\n lean: true,\n ordered: true,\n });\n return response as unknown as T[];\n } catch (e) {\n this.logger.error(e, 'Unable to bulk create due to error [%s]', e.message);\n }\n }\n\n public async upsert<I>(conditions: FilterQuery<D>, update: I, options?: Record<string, unknown>): Promise<T> {\n return this.update<I>(conditions, update, {\n upsert: true,\n ...options,\n });\n }\n\n public async bulkUpdate<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T[]> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const res = await this.model.updateMany(processedCriteria, update);\n if (res) {\n const response = await this.model.find(processedCriteria).exec();\n return response.map((i) => i?.toObject()) as T[];\n } else {\n this.logger.error('Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw new Error('Unable to do bulk update');\n }\n } catch (e) {\n this.logger.error(e, 'Unable to Bulk Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async update<I>(\n criteria: FilterQuery<D>,\n update: UpdateQuery<D>,\n options: Record<string, unknown>,\n ): Promise<T> {\n try {\n const { id, ...rest } = criteria;\n const processedCriteria = id ? { _id: id, ...rest } : criteria;\n const mergedOptions = {\n new: true,\n useFindAndModify: false,\n ...options,\n };\n if (id) {\n return (await this.model\n .findByIdAndUpdate(id, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n }\n return (await this.model\n .findOneAndUpdate(processedCriteria, update as unknown as never, mergedOptions)\n .exec()) as unknown as Promise<T>;\n } catch (e) {\n this.logger.error(e, 'Unable to Update with criteria [%j] and data [%j]', criteria, update);\n throw e;\n }\n }\n\n public async delete(criteria: FilterQuery<D>): Promise<boolean> {\n try {\n let deleted;\n if (criteria?.id) {\n deleted = await this.model.findByIdAndDelete(criteria.id);\n } else {\n deleted = await this.model.findOneAndDelete(this.mapConditions(criteria));\n }\n return !!deleted;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n\n public async bulkDelete(criteria: FilterQuery<D>): Promise<number> {\n try {\n const deleted = await this.model.deleteMany(this.mapConditions(criteria));\n return deleted?.deletedCount || 0;\n } catch (e) {\n this.logger.error(e, 'Unable to delete the model with criteria [%j]', criteria);\n throw e;\n }\n }\n}\n"],"names":["mongoose"],"mappings":";AASA,MAAM,EAAE,KAAK,EAAE,GAAGA,iBAAQ,CAAC;AAG3B;;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+CAA+C,EAAE,QAAQ,CAAC,CAAC;AAChF,YAAA,MAAM,CAAC,CAAC;SACX;KACJ;IAEM,MAAM,UAAU,CAAC,QAAwB,EAAA;AAC5C,QAAA,IAAI;AACA,YAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC1E,YAAA,OAAO,OAAO,EAAE,YAAY,IAAI,CAAC,CAAC;SACrC;QAAC,OAAO,CAAC,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,+CAA+C,EAAE,QAAQ,CAAC,CAAC;AAChF,YAAA,MAAM,CAAC,CAAC;SACX;KACJ;EACJ;AA/QY,cAAc,GAAA,gBAAA,GAAA,UAAA,CAAA;AAD1B,IAAA,UAAU,EAAE;IASJ,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;IAEX,OAAA,CAAA,CAAA,EAAA,SAAS,EAAE,CAAA;;AAdP,CAAA,EAAA,cAAc,CA+Q1B"}
@@ -170,7 +170,7 @@ export interface IBaseService<SchemaType, CreateInterface = CreateType<SchemaTyp
170
170
  * true
171
171
  * );
172
172
  */
173
- update(id: string, data: Partial<UpdateInterface>, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
173
+ update(id: string, data: UpdateInterface, overwrite?: boolean): Promise<AsDomainType<SchemaType>>;
174
174
 
175
175
  /**
176
176
  * Creates a new document or updates it if ID is provided
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/store-mongo",
3
- "version": "8.2.5-alpha.11",
3
+ "version": "8.2.5-alpha.15",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "UNLICENSED",
6
6
  "author": "CDMBase LLC",
@@ -24,11 +24,11 @@
24
24
  "watch": "npm run build:lib:watch"
25
25
  },
26
26
  "dependencies": {
27
- "@common-stack/core": "8.2.5-alpha.10",
27
+ "@common-stack/core": "8.2.5-alpha.15",
28
28
  "mongoose-lean-virtuals": "^0.9.1"
29
29
  },
30
30
  "devDependencies": {
31
- "common": "8.2.5-alpha.10",
31
+ "common": "8.2.5-alpha.15",
32
32
  "moleculer": "^0.14.33",
33
33
  "mongoose": "^6.12.8"
34
34
  },
@@ -56,8 +56,8 @@
56
56
  ]
57
57
  }
58
58
  },
59
- "gitHead": "89c4fb7c96307851ebc2b515223f0f68f7ecf44d",
60
59
  "typescript": {
61
60
  "definition": "lib/index.d.ts"
62
- }
61
+ },
62
+ "gitHead": "c037b8613fd70c9dc85ffb654ed7c123ef60c4f0"
63
63
  }