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

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.
@@ -69,7 +69,7 @@ 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;
72
+ _id?: ObjectId;
73
73
  } & {
74
74
  id: string;
75
75
  };
@@ -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, 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"}
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 } & { 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"}
@@ -127,7 +127,7 @@ export interface IBaseServiceMixinActions {
127
127
  type: 'array',
128
128
  items: 'string',
129
129
  optional: false
130
- },;
130
+ };
131
131
  };
132
132
  };
133
133
 
@@ -83,7 +83,7 @@ export interface GetAllArgs<T> {
83
83
  * // email: string;
84
84
  * // }
85
85
  */
86
- export type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & { _id?: ObjectId | string } & { id: string };
86
+ export type AsDomainType<SchemaType> = Omit<SchemaType, '_id'> & { _id?: ObjectId } & { id: string };
87
87
 
88
88
  /**
89
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.44",
3
+ "version": "7.1.1-alpha.48",
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.44"
27
+ "@common-stack/core": "7.1.1-alpha.48"
28
28
  },
29
29
  "devDependencies": {
30
- "common": "7.1.1-alpha.44",
30
+ "common": "7.1.1-alpha.48",
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": "1900c85a0ceeeb5ce5fb97025e4d8c79298e52ae"
61
+ "gitHead": "117c42009849467645b01b2c146c201080f0163f"
62
62
  }