@common-stack/store-mongo 7.1.1-alpha.42 → 7.1.1-alpha.44

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.
@@ -28,7 +28,7 @@
28
28
  * @see IBaseService2 - Implements service methods using these types
29
29
  * @see IDataLoader2 - Utilizes these types for efficient data loading
30
30
  */
31
- import type { FilterQuery } from 'mongoose';
31
+ import type { FilterQuery, ObjectId } from 'mongoose';
32
32
  import type { ISort } from 'common';
33
33
  /**
34
34
  * Interface for the arguments used in the getAll method
@@ -69,6 +69,8 @@ export interface GetAllArgs<T> {
69
69
  * const user: AsDomainType<UserSchema> = { id: '123', name: 'John', email: 'john@example.com' };
70
70
  */
71
71
  export type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & {
72
+ _id?: ObjectId | string;
73
+ } & {
72
74
  id: string;
73
75
  };
74
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"getAllArgs.js","sources":["../../src/interfaces/getAllArgs.ts"],"sourcesContent":["/**\n * @file get-all-args.ts\n * @description Defines common types and interfaces used across the data access layer for MongoDB operations.\n * This file contains essential type definitions that standardize how data is queried, transformed, and returned.\n *\n * Key components include:\n * - GetAllArgs: Interface for pagination, sorting, and filtering when retrieving collections of documents\n * - AsDomainType: Type transformer that converts MongoDB schema types (with _id) to domain types (with id)\n * - GetAllWithCountResult: Type for paginated results that include both data and total count\n * - CreateType/UpdateType: Utility types that define the shape of data for create and update operations\n * - PAGINATION_OPTIONS: Default pagination settings used throughout the application\n *\n * Usage examples:\n * 1. Retrieving paginated data:\n * const result = await repository.getAllWithCount({ limit: 10, skip: 0, sort: { createdAt: -1 } });\n *\n * 2. Converting MongoDB documents to domain objects:\n * const domainUser: AsDomainType<UserSchema> = { ...userDoc, id: userDoc._id.toString() };\n *\n * 3. Creating new documents with proper typing:\n * const newUser: CreateType<UserSchema> = { name: 'John', email: 'john@example.com' };\n *\n * These types ensure consistency across repositories and services, providing type safety and\n * clear contracts for data manipulation throughout the application. They form the foundation\n * of the data access pattern used across the entire system.\n *\n * @see IBaseMongoRepository - Uses these types for repository operations\n * @see IBaseService2 - Implements service methods using these types\n * @see IDataLoader2 - Utilizes these types for efficient data loading\n */\n\nimport type { FilterQuery } from 'mongoose';\nimport type { ISort } from 'common';\n\n/**\n * Interface for the arguments used in the getAll method\n *\n * @property criteria - MongoDB filter query to narrow down results\n * @property sort - Sorting configuration with field names and directions (1 for ascending, -1 for descending)\n * @property skip - Number of documents to skip (for pagination)\n * @property limit - Maximum number of documents to return (for pagination)\n * @property selectedFields - String of space-separated field names to include in the results\n *\n * @example\n * // Get active users, sorted by creation date, second page with 10 items per page\n * const options: GetAllArgs<UserSchema> = {\n * criteria: { active: true },\n * sort: { createdAt: -1 },\n * skip: 10,\n * limit: 10,\n * selectedFields: 'name email createdAt'\n * };\n */\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n\n/**\n * Type that converts a schema type with _id to a domain type with id\n * This transformation is essential for presenting MongoDB documents as domain objects\n * throughout the application, hiding the database-specific _id field.\n *\n * @example\n * // MongoDB document\n * const userDoc = { _id: '123', name: 'John', email: 'john@example.com' };\n *\n * // Transformed domain object\n * const user: AsDomainType<UserSchema> = { id: '123', name: 'John', email: 'john@example.com' };\n */\nexport type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & { id: string };\n\n/**\n * Type for the result of getAllWithCount\n * Provides both the paginated data and the total count of matching documents\n * This is used for implementing pagination UI components that need to know\n * the total number of pages or items.\n *\n * @property data - Array of domain objects matching the query criteria\n * @property totalCount - Total number of documents that match the criteria (without pagination)\n *\n * @example\n * const result: GetAllWithCountResult<UserSchema> = {\n * data: [{ id: '1', name: 'John' }, { id: '2', name: 'Jane' }],\n * totalCount: 50\n * };\n */\nexport type GetAllWithCountResult<SchemaType> = {\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n};\n\n/**\n * Default pagination settings used throughout the application\n * These values are used when no explicit pagination parameters are provided\n */\nexport enum PAGINATION_OPTIONS {\n limit = 10,\n skip = 0,\n}\n\n/**\n * Type for create operations - omits _id, id, and auto-generated fields\n * This ensures that clients cannot specify fields that should be generated by the database\n *\n * @example\n * // Valid create operation data\n * const newUser: CreateType<UserSchema> = {\n * name: 'John Doe',\n * email: 'john@example.com',\n * role: 'user'\n * };\n *\n * // The following fields will be generated automatically and should not be included:\n * // - _id (MongoDB document ID)\n * // - id (Domain object ID)\n * // - createdAt (Creation timestamp)\n * // - updatedAt (Last update timestamp)\n */\nexport type CreateType<SchemaType> = Omit<Partial<SchemaType>, '_id' | 'id' | 'createdAt' | 'updatedAt'>;\n\n/**\n * Type for update operations - partial of the schema without _id\n * This allows for partial updates where only changed fields are specified\n *\n * @example\n * // Update a user's email and role\n * const updateData: UpdateType<UserSchema> = {\n * email: 'new.email@example.com',\n * role: 'admin'\n * };\n *\n * // Fields not specified will remain unchanged\n */\nexport type UpdateType<SchemaType> = Partial<Omit<SchemaType, '_id'>>;\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AAkEH;;;AAGG;IACS,mBAGX;AAHD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,EAAA,CAAA,GAAA,OAAU,CAAA;AACV,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACZ,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"getAllArgs.js","sources":["../../src/interfaces/getAllArgs.ts"],"sourcesContent":["/**\n * @file get-all-args.ts\n * @description Defines common types and interfaces used across the data access layer for MongoDB operations.\n * This file contains essential type definitions that standardize how data is queried, transformed, and returned.\n *\n * Key components include:\n * - GetAllArgs: Interface for pagination, sorting, and filtering when retrieving collections of documents\n * - AsDomainType: Type transformer that converts MongoDB schema types (with _id) to domain types (with id)\n * - GetAllWithCountResult: Type for paginated results that include both data and total count\n * - CreateType/UpdateType: Utility types that define the shape of data for create and update operations\n * - PAGINATION_OPTIONS: Default pagination settings used throughout the application\n *\n * Usage examples:\n * 1. Retrieving paginated data:\n * const result = await repository.getAllWithCount({ limit: 10, skip: 0, sort: { createdAt: -1 } });\n *\n * 2. Converting MongoDB documents to domain objects:\n * const domainUser: AsDomainType<UserSchema> = { ...userDoc, id: userDoc._id.toString() };\n *\n * 3. Creating new documents with proper typing:\n * const newUser: CreateType<UserSchema> = { name: 'John', email: 'john@example.com' };\n *\n * These types ensure consistency across repositories and services, providing type safety and\n * clear contracts for data manipulation throughout the application. They form the foundation\n * of the data access pattern used across the entire system.\n *\n * @see IBaseMongoRepository - Uses these types for repository operations\n * @see IBaseService2 - Implements service methods using these types\n * @see IDataLoader2 - Utilizes these types for efficient data loading\n */\n\nimport type { FilterQuery, ObjectId } from 'mongoose';\nimport type { ISort } from 'common';\n\n/**\n * Interface for the arguments used in the getAll method\n *\n * @property criteria - MongoDB filter query to narrow down results\n * @property sort - Sorting configuration with field names and directions (1 for ascending, -1 for descending)\n * @property skip - Number of documents to skip (for pagination)\n * @property limit - Maximum number of documents to return (for pagination)\n * @property selectedFields - String of space-separated field names to include in the results\n *\n * @example\n * // Get active users, sorted by creation date, second page with 10 items per page\n * const options: GetAllArgs<UserSchema> = {\n * criteria: { active: true },\n * sort: { createdAt: -1 },\n * skip: 10,\n * limit: 10,\n * selectedFields: 'name email createdAt'\n * };\n */\nexport interface GetAllArgs<T> {\n criteria?: FilterQuery<T>;\n sort?: ISort;\n skip?: number;\n limit?: number;\n selectedFields?: string;\n}\n\n/**\n * Type that converts a schema type with _id to a domain type with id\n * This transformation is essential for presenting MongoDB documents as domain objects\n * throughout the application, hiding the database-specific _id field.\n *\n * @example\n * // MongoDB document\n * const userDoc = { _id: '123', name: 'John', email: 'john@example.com' };\n *\n * // Transformed domain object\n * const user: AsDomainType<UserSchema> = { id: '123', name: 'John', email: 'john@example.com' };\n */\nexport type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & { _id?: ObjectId | string } & { id: string };\n\n/**\n * Type for the result of getAllWithCount\n * Provides both the paginated data and the total count of matching documents\n * This is used for implementing pagination UI components that need to know\n * the total number of pages or items.\n *\n * @property data - Array of domain objects matching the query criteria\n * @property totalCount - Total number of documents that match the criteria (without pagination)\n *\n * @example\n * const result: GetAllWithCountResult<UserSchema> = {\n * data: [{ id: '1', name: 'John' }, { id: '2', name: 'Jane' }],\n * totalCount: 50\n * };\n */\nexport type GetAllWithCountResult<SchemaType> = {\n data: AsDomainType<SchemaType>[];\n totalCount: number;\n};\n\n/**\n * Default pagination settings used throughout the application\n * These values are used when no explicit pagination parameters are provided\n */\nexport enum PAGINATION_OPTIONS {\n limit = 10,\n skip = 0,\n}\n\n/**\n * Type for create operations - omits _id, id, and auto-generated fields\n * This ensures that clients cannot specify fields that should be generated by the database\n *\n * @example\n * // Valid create operation data\n * const newUser: CreateType<UserSchema> = {\n * name: 'John Doe',\n * email: 'john@example.com',\n * role: 'user'\n * };\n *\n * // The following fields will be generated automatically and should not be included:\n * // - _id (MongoDB document ID)\n * // - id (Domain object ID)\n * // - createdAt (Creation timestamp)\n * // - updatedAt (Last update timestamp)\n */\nexport type CreateType<SchemaType> = Omit<Partial<SchemaType>, '_id' | 'id' | 'createdAt' | 'updatedAt'>;\n\n/**\n * Type for update operations - partial of the schema without _id\n * This allows for partial updates where only changed fields are specified\n *\n * @example\n * // Update a user's email and role\n * const updateData: UpdateType<UserSchema> = {\n * email: 'new.email@example.com',\n * role: 'admin'\n * };\n *\n * // Fields not specified will remain unchanged\n */\nexport type UpdateType<SchemaType> = Partial<Omit<SchemaType, '_id'>>;\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BG;AAkEH;;;AAGG;IACS,mBAGX;AAHD,CAAA,UAAY,kBAAkB,EAAA;AAC1B,IAAA,kBAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,GAAA,EAAA,CAAA,GAAA,OAAU,CAAA;AACV,IAAA,kBAAA,CAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ,CAAA;AACZ,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA"}
@@ -68,7 +68,11 @@ const BaseServiceMixin = (service, broker, name, events = defaultEvents) => ({
68
68
  */
69
69
  [BaseServiceCommands.GetByIds]: {
70
70
  params: {
71
- ids: 'string',
71
+ ids: {
72
+ type: 'array',
73
+ items: 'string',
74
+ optional: false
75
+ },
72
76
  },
73
77
  handler: async (ctx) => service.getByIds(ctx.params.ids),
74
78
  },
@@ -1 +1 @@
1
- {"version":3,"file":"BaseServiceMixin.js","sources":["../../src/mixins/BaseServiceMixin.ts"],"sourcesContent":["/**\n * @file BaseServiceMixin.ts\n * @description Provides a mixin function that adds standardized service methods to Moleculer service schemas.\n * This mixin implements the IBaseService interface and connects it to Moleculer's service framework,\n * creating action handlers for all standard service operations.\n *\n * The mixin pattern allows for composable service functionality, where multiple mixins can be combined\n * to create feature-rich services without code duplication. This particular mixin handles the core CRUD\n * operations and emits events when data changes.\n *\n * Key features:\n * - Automatic action creation for all IBaseService methods\n * - Event emission for data changes (create, update, delete)\n * - Parameter validation for all actions\n * - Consistent error handling\n * - Type safety through generics\n *\n * @see IBaseService - The interface this mixin implements\n * @see IBaseMongoRepository - The repository interface used for data access\n */\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { Context, ServiceBroker, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { upperFirst } from 'lodash-es';\nimport { GetAllArgs, IBaseService, BaseServiceCommands } from 'common';\n\n/**\n * Default events that will trigger event emissions when data changes\n * Services can customize this list to control which operations emit events\n */\nconst defaultEvents = [\n BaseServiceCommands.Create,\n BaseServiceCommands.BulkCreate,\n BaseServiceCommands.Update,\n BaseServiceCommands.Delete,\n BaseServiceCommands.DeleteMany,\n];\n\n/**\n * Creates a mixin that implements the IBaseService interface as Moleculer actions\n *\n * @param service - Implementation of IBaseService that will handle the actual business logic\n * @param broker - Moleculer service broker for event emission\n * @param name - Service name used for event naming\n * @param events - List of operations that should emit events\n * @returns A partial ServiceSchema that can be merged with other service definitions\n *\n * @example\n * // Create a user service with the base service mixin\n * const UserService: ServiceSchema = {\n * name: \"users\",\n * mixins: [\n * BaseServiceMixin(userService, broker, \"users\")\n * ],\n * // Additional service-specific actions and methods\n * actions: {\n * changePassword: { ... }\n * }\n * };\n */\nexport const BaseServiceMixin = <T>(\n service: IBaseService<T>,\n broker?: ServiceBroker,\n name?: string,\n events = defaultEvents,\n): Partial<ServiceSchema> => ({\n name: 'BaseServiceMixin',\n actions: {\n /**\n * Get a single document by ID\n */\n [BaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) =>\n service.get({ id: ctx.params.id } as FilterQuery<Document<T>>),\n },\n\n /**\n * Get multiple documents by their IDs\n */\n [BaseServiceCommands.GetByIds]: {\n params: {\n ids: 'string',\n },\n handler: async (ctx: Context<{ ids: string[] }>) => service.getByIds(ctx.params.ids),\n },\n\n /**\n * Count documents matching criteria\n */\n [BaseServiceCommands.Count]: {\n params: {\n criteria: { type: 'object', optional: true },\n },\n handler: async (ctx: Context<{ criteria?: FilterQuery<Document<T>> }>) =>\n service.count(ctx.params.criteria),\n },\n\n /**\n * Create multiple documents\n */\n [BaseServiceCommands.BulkCreate]: {\n params: {\n data: { type: 'array', items: 'object' },\n },\n handler: async (ctx: Context<{ data: never[] }>) => {\n const response = await service.bulkCreate(ctx.params.data);\n if (events.includes(BaseServiceCommands.BulkCreate)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.BulkCreate)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Create a single document\n */\n [BaseServiceCommands.Create]: {\n params: {\n data: 'object',\n },\n handler: async (ctx: Context<{ data: never }>) => {\n const response = await service.create(ctx.params.data);\n if (events.includes(BaseServiceCommands.Create)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Create)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete a document by ID\n */\n [BaseServiceCommands.Delete]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => {\n const { id } = ctx.params;\n const response = await service.delete({ id } as FilterQuery<Document<T>>);\n if (events.includes(BaseServiceCommands.Delete)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Delete)}`, { id });\n }\n return response;\n },\n },\n\n /**\n * Get documents with pagination\n */\n [BaseServiceCommands.GetAll]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAll(ctx.params),\n },\n\n /**\n * Get documents with pagination and total count\n */\n [BaseServiceCommands.GetAllWithCount]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAllWithCount(ctx.params),\n },\n\n /**\n * Create or update a document\n */\n [BaseServiceCommands.Insert]: {\n params: {\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ data: never & { id?: string }; overwrite: boolean }>) => {\n const { data } = ctx.params;\n const response = await service.insert(data, ctx.params.overwrite);\n const action = (data as { id: string })?.id ? BaseServiceCommands.Update : BaseServiceCommands.Create;\n if (events.includes(action)) {\n await broker?.emit(`${name}.on${upperFirst(action)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Update a document by ID\n */\n [BaseServiceCommands.Update]: {\n params: {\n id: 'string',\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ id: string; data: never; overwrite: boolean }>) => {\n const response = await service.update(ctx.params.id, ctx.params.data, ctx.params.overwrite);\n if (events.includes(BaseServiceCommands.Update)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Update)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete multiple documents matching criteria\n */\n [BaseServiceCommands.DeleteMany]: {\n params: {\n criteria: 'object',\n },\n handler: async (ctx: Context<{ criteria: FilterQuery<Document<T>> }>) => {\n const { criteria } = ctx.params;\n const response = await service.delete(criteria);\n if (events.includes(BaseServiceCommands.DeleteMany)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.DeleteMany)}`, criteria);\n }\n return response;\n },\n },\n },\n});\n"],"names":[],"mappings":"4EAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAQH;;;AAGG;AACH,MAAM,aAAa,GAAG;AAClB,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;AAC9B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,MAAM;AAC1B,IAAA,mBAAmB,CAAC,UAAU;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;AAqBG;AACU,MAAA,gBAAgB,GAAG,CAC5B,OAAwB,EACxB,MAAsB,EACtB,IAAa,EACb,MAAM,GAAG,aAAa,MACI;AAC1B,IAAA,IAAI,EAAE,kBAAkB;AACxB,IAAA,OAAO,EAAE;AACL;;AAEG;AACH,QAAA,CAAC,mBAAmB,CAAC,GAAG,GAAG;AACvB,YAAA,MAAM,EAAE;AACJ,gBAAA,EAAE,EAAE,QAAQ;AACf,aAAA;YACD,OAAO,EAAE,OAAO,GAA4B,KACxC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,EAA8B,CAAC;AACrE,SAAA;AAED;;AAEG;AACH,QAAA,CAAC,mBAAmB,CAAC,QAAQ,GAAG;AAC5B,YAAA,MAAM,EAAE;AACJ,gBAAA,GAAG,EAAE,QAAQ;AAChB,aAAA;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AA"}
1
+ {"version":3,"file":"BaseServiceMixin.js","sources":["../../src/mixins/BaseServiceMixin.ts"],"sourcesContent":["/**\n * @file BaseServiceMixin.ts\n * @description Provides a mixin function that adds standardized service methods to Moleculer service schemas.\n * This mixin implements the IBaseService interface and connects it to Moleculer's service framework,\n * creating action handlers for all standard service operations.\n *\n * The mixin pattern allows for composable service functionality, where multiple mixins can be combined\n * to create feature-rich services without code duplication. This particular mixin handles the core CRUD\n * operations and emits events when data changes.\n *\n * Key features:\n * - Automatic action creation for all IBaseService methods\n * - Event emission for data changes (create, update, delete)\n * - Parameter validation for all actions\n * - Consistent error handling\n * - Type safety through generics\n *\n * @see IBaseService - The interface this mixin implements\n * @see IBaseMongoRepository - The repository interface used for data access\n */\n\n/* eslint-disable import/no-extraneous-dependencies */\nimport { Context, ServiceBroker, ServiceSchema } from 'moleculer';\nimport { Document, FilterQuery } from 'mongoose';\nimport { upperFirst } from 'lodash-es';\nimport { GetAllArgs, IBaseService, BaseServiceCommands } from 'common';\n\n/**\n * Default events that will trigger event emissions when data changes\n * Services can customize this list to control which operations emit events\n */\nconst defaultEvents = [\n BaseServiceCommands.Create,\n BaseServiceCommands.BulkCreate,\n BaseServiceCommands.Update,\n BaseServiceCommands.Delete,\n BaseServiceCommands.DeleteMany,\n];\n\n/**\n * Creates a mixin that implements the IBaseService interface as Moleculer actions\n *\n * @param service - Implementation of IBaseService that will handle the actual business logic\n * @param broker - Moleculer service broker for event emission\n * @param name - Service name used for event naming\n * @param events - List of operations that should emit events\n * @returns A partial ServiceSchema that can be merged with other service definitions\n *\n * @example\n * // Create a user service with the base service mixin\n * const UserService: ServiceSchema = {\n * name: \"users\",\n * mixins: [\n * BaseServiceMixin(userService, broker, \"users\")\n * ],\n * // Additional service-specific actions and methods\n * actions: {\n * changePassword: { ... }\n * }\n * };\n */\nexport const BaseServiceMixin = <T>(\n service: IBaseService<T>,\n broker?: ServiceBroker,\n name?: string,\n events = defaultEvents,\n): Partial<ServiceSchema> => ({\n name: 'BaseServiceMixin',\n actions: {\n /**\n * Get a single document by ID\n */\n [BaseServiceCommands.Get]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) =>\n service.get({ id: ctx.params.id } as FilterQuery<Document<T>>),\n },\n\n /**\n * Get multiple documents by their IDs\n */\n [BaseServiceCommands.GetByIds]: {\n params: {\n ids: { \n type: 'array', \n items: 'string',\n optional: false\n },\n },\n handler: async (ctx: Context<{ ids: string[] }>) => service.getByIds(ctx.params.ids),\n },\n\n /**\n * Count documents matching criteria\n */\n [BaseServiceCommands.Count]: {\n params: {\n criteria: { type: 'object', optional: true },\n },\n handler: async (ctx: Context<{ criteria?: FilterQuery<Document<T>> }>) =>\n service.count(ctx.params.criteria),\n },\n\n /**\n * Create multiple documents\n */\n [BaseServiceCommands.BulkCreate]: {\n params: {\n data: { type: 'array', items: 'object' },\n },\n handler: async (ctx: Context<{ data: never[] }>) => {\n const response = await service.bulkCreate(ctx.params.data);\n if (events.includes(BaseServiceCommands.BulkCreate)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.BulkCreate)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Create a single document\n */\n [BaseServiceCommands.Create]: {\n params: {\n data: 'object',\n },\n handler: async (ctx: Context<{ data: never }>) => {\n const response = await service.create(ctx.params.data);\n if (events.includes(BaseServiceCommands.Create)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Create)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete a document by ID\n */\n [BaseServiceCommands.Delete]: {\n params: {\n id: 'string',\n },\n handler: async (ctx: Context<{ id: string }>) => {\n const { id } = ctx.params;\n const response = await service.delete({ id } as FilterQuery<Document<T>>);\n if (events.includes(BaseServiceCommands.Delete)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Delete)}`, { id });\n }\n return response;\n },\n },\n\n /**\n * Get documents with pagination\n */\n [BaseServiceCommands.GetAll]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAll(ctx.params),\n },\n\n /**\n * Get documents with pagination and total count\n */\n [BaseServiceCommands.GetAllWithCount]: {\n params: {\n criteria: 'object|optional',\n sort: 'object|optional',\n skip: 'number|optional',\n limit: 'number|optional',\n selectedFields: 'string|optional',\n },\n handler: async (ctx: Context<GetAllArgs<Document<T>>>) => service.getAllWithCount(ctx.params),\n },\n\n /**\n * Create or update a document\n */\n [BaseServiceCommands.Insert]: {\n params: {\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ data: never & { id?: string }; overwrite: boolean }>) => {\n const { data } = ctx.params;\n const response = await service.insert(data, ctx.params.overwrite);\n const action = (data as { id: string })?.id ? BaseServiceCommands.Update : BaseServiceCommands.Create;\n if (events.includes(action)) {\n await broker?.emit(`${name}.on${upperFirst(action)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Update a document by ID\n */\n [BaseServiceCommands.Update]: {\n params: {\n id: 'string',\n data: 'object',\n overwrite: 'boolean|optional',\n },\n handler: async (ctx: Context<{ id: string; data: never; overwrite: boolean }>) => {\n const response = await service.update(ctx.params.id, ctx.params.data, ctx.params.overwrite);\n if (events.includes(BaseServiceCommands.Update)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.Update)}`, response);\n }\n return response;\n },\n },\n\n /**\n * Delete multiple documents matching criteria\n */\n [BaseServiceCommands.DeleteMany]: {\n params: {\n criteria: 'object',\n },\n handler: async (ctx: Context<{ criteria: FilterQuery<Document<T>> }>) => {\n const { criteria } = ctx.params;\n const response = await service.delete(criteria);\n if (events.includes(BaseServiceCommands.DeleteMany)) {\n await broker?.emit(`${name}.on${upperFirst(BaseServiceCommands.DeleteMany)}`, criteria);\n }\n return response;\n },\n },\n },\n});\n"],"names":[],"mappings":"4EAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAQH;;;AAG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AM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE;AAC7C,oBAAA,MAAM,MAAM,EAAE,IAAI,CAAC,CAAA,EAAG,IAAI,CAAM,GAAA,EAAA,UAAU,CAAC,mBAAmB,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBACvF;AACD,gBAAA,OAAO,QAAQ,CAAC;aACnB;AACJ,SAAA;AAED;;AAEG;AACH,QAAA,CAAC,mBAAmB,CAAC,UAAU,GAAG;AAC9B,YAAA,MAAM,EAAE;AACJ,gBAAA,QAAQ,EAAE,QAAQ;AACrB,aAAA;AACD,YAAA,OAAO,EAAE,OAAO,GAAoD,KAAI;AACpE,gBAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;gBAChC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAChD,IAAI,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;AACjD,oBAAA,MAAM,MAAM,EAAE,IAAI,CAAC,CAAA,EAAG,IAAI,CAAM,GAAA,EAAA,UAAU,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;iBAC3F;AACD,gBAAA,OAAO,QAAQ,CAAC;aACnB;AACJ,SAAA;AACJ,KAAA;AACJ,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
package/lib/module.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { Feature } from '@common-stack/server-core';
2
- declare const _default: Feature<import("@common-stack/server-core").ConfigurationScope, any>;
1
+ declare const _default: any;
3
2
  export default _default;
@@ -123,7 +123,11 @@ export interface IBaseServiceMixinActions {
123
123
  */
124
124
  [BaseServiceCommands.GetByIds]: {
125
125
  params: {
126
- ids: string[];
126
+ ids: {
127
+ type: 'array',
128
+ items: 'string',
129
+ optional: false
130
+ },;
127
131
  };
128
132
  };
129
133
 
@@ -20,6 +20,7 @@
20
20
  * @see IBaseMongoRepository - MongoDB repository implementation using these types
21
21
  */
22
22
  import { ISort } from 'common';
23
+ import type { ObjectId } from 'mongoose';
23
24
  /**
24
25
  * Generic filter type that doesn't depend on specific database implementation
25
26
  * Can be used for any database query operations
@@ -82,7 +83,7 @@ export interface GetAllArgs<T> {
82
83
  * // email: string;
83
84
  * // }
84
85
  */
85
- export type AsDomainType<T> = T & { id: string };
86
+ export type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & { _id?: ObjectId | string } & { id: string };
86
87
 
87
88
  /**
88
89
  * Type for paginated results that include both data and total count
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/store-mongo",
3
- "version": "7.1.1-alpha.42",
3
+ "version": "7.1.1-alpha.44",
4
4
  "description": "Sample core for higher packages to depend on",
5
5
  "license": "ISC",
6
6
  "author": "CDMBase LLC",
@@ -24,10 +24,10 @@
24
24
  "watch": "npm run build:lib:watch"
25
25
  },
26
26
  "dependencies": {
27
- "@common-stack/core": "7.1.1-alpha.42"
27
+ "@common-stack/core": "7.1.1-alpha.44"
28
28
  },
29
29
  "devDependencies": {
30
- "common": "7.1.1-alpha.42",
30
+ "common": "7.1.1-alpha.44",
31
31
  "moleculer": "^0.14.33",
32
32
  "mongoose": "^6.12.8"
33
33
  },
@@ -58,5 +58,5 @@
58
58
  "typescript": {
59
59
  "definition": "lib/index.d.ts"
60
60
  },
61
- "gitHead": "0c9db3d8ba17c8e292786cded8aa3984729d7e1d"
61
+ "gitHead": "1900c85a0ceeeb5ce5fb97025e4d8c79298e52ae"
62
62
  }