@classytic/mongokit 3.3.2 → 3.4.0

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,4 +1,4 @@
1
- import * as mongoose$1 from "mongoose";
1
+ import * as _$mongoose from "mongoose";
2
2
  import { ClientSession, Document, Model, PipelineStage, PopulateOptions, Types } from "mongoose";
3
3
 
4
4
  //#region src/query/LookupBuilder.d.ts
@@ -13,6 +13,8 @@ interface LookupOptions {
13
13
  as?: string;
14
14
  /** Whether to unwrap array to single object */
15
15
  single?: boolean;
16
+ /** Field selection on the joined collection (shorthand for $project pipeline) */
17
+ select?: string | Record<string, 0 | 1>;
16
18
  /** Additional pipeline to run on the joined collection */
17
19
  pipeline?: PipelineStage[];
18
20
  /** Optional let variables for pipeline */
@@ -451,7 +453,7 @@ interface IResponseFormatter {
451
453
  //#endregion
452
454
  //#region src/types.d.ts
453
455
  /** Read Preference Type for replica sets */
454
- type ReadPreferenceType = "primary" | "primaryPreferred" | "secondary" | "secondaryPreferred" | "nearest" | (string & {});
456
+ type ReadPreferenceType = 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest' | (string & {});
455
457
  /** Re-export mongoose ObjectId */
456
458
  type ObjectId = Types.ObjectId;
457
459
  /** Generic document type */
@@ -514,10 +516,10 @@ type NonNullableFields<T> = { [K in keyof T]: NonNullable<T[K]> };
514
516
  /**
515
517
  * Create/Update input types from document
516
518
  */
517
- type CreateInput<TDoc> = Omit<TDoc, "_id" | "createdAt" | "updatedAt" | "__v">;
518
- type UpdateInput<TDoc> = Partial<Omit<TDoc, "_id" | "createdAt" | "__v">>;
519
+ type CreateInput<TDoc> = Omit<TDoc, '_id' | 'createdAt' | 'updatedAt' | '__v'>;
520
+ type UpdateInput<TDoc> = Partial<Omit<TDoc, '_id' | 'createdAt' | '__v'>>;
519
521
  /** Hook execution mode */
520
- type HookMode = "sync" | "async";
522
+ type HookMode = 'sync' | 'async';
521
523
  /** Repository options */
522
524
  interface RepositoryOptions {
523
525
  /** Whether repository event hooks are awaited */
@@ -541,7 +543,7 @@ interface PaginationConfig {
541
543
  /** Base pagination options */
542
544
  interface BasePaginationOptions {
543
545
  /** Pagination mode (explicit override) */
544
- mode?: "offset" | "keyset";
546
+ mode?: 'offset' | 'keyset';
545
547
  /** MongoDB query filters */
546
548
  filters?: FilterQuery<AnyDocument>;
547
549
  /** Sort specification */
@@ -568,7 +570,7 @@ interface OffsetPaginationOptions extends BasePaginationOptions {
568
570
  /** Page number (1-indexed) */
569
571
  page?: number;
570
572
  /** Count strategy for filtered queries (default: 'exact') */
571
- countStrategy?: "exact" | "estimated" | "none";
573
+ countStrategy?: 'exact' | 'estimated' | 'none';
572
574
  }
573
575
  /** Keyset (cursor) pagination options */
574
576
  interface KeysetPaginationOptions extends BasePaginationOptions {
@@ -592,16 +594,16 @@ interface AggregatePaginationOptions {
592
594
  /** Maximum execution time in milliseconds */
593
595
  maxTimeMS?: number;
594
596
  /** Count strategy (default: 'exact' via $facet) */
595
- countStrategy?: "exact" | "estimated" | "none";
597
+ countStrategy?: 'exact' | 'estimated' | 'none';
596
598
  /** Pagination mode (reserved for API consistency) */
597
- mode?: "offset";
599
+ mode?: 'offset';
598
600
  /** Read preference for replica sets (e.g. 'secondaryPreferred') */
599
601
  readPreference?: ReadPreferenceType;
600
602
  }
601
603
  /** Offset pagination result */
602
604
  interface OffsetPaginationResult<T = unknown> {
603
605
  /** Pagination method used */
604
- method: "offset";
606
+ method: 'offset';
605
607
  /** Array of documents */
606
608
  docs: T[];
607
609
  /** Current page number */
@@ -622,7 +624,7 @@ interface OffsetPaginationResult<T = unknown> {
622
624
  /** Keyset pagination result */
623
625
  interface KeysetPaginationResult<T = unknown> {
624
626
  /** Pagination method used */
625
- method: "keyset";
627
+ method: 'keyset';
626
628
  /** Array of documents */
627
629
  docs: T[];
628
630
  /** Documents per page */
@@ -635,7 +637,7 @@ interface KeysetPaginationResult<T = unknown> {
635
637
  /** Aggregate pagination result */
636
638
  interface AggregatePaginationResult<T = unknown> {
637
639
  /** Pagination method used */
638
- method: "aggregate";
640
+ method: 'aggregate';
639
641
  /** Array of documents */
640
642
  docs: T[];
641
643
  /** Current page number */
@@ -670,7 +672,7 @@ interface OperationOptions {
670
672
  /** Additional query filters (e.g., for soft delete) */
671
673
  query?: Record<string, unknown>;
672
674
  /** Read preference for replica sets (e.g. 'secondaryPreferred') */
673
- readPreference?: "primary" | "primaryPreferred" | "secondary" | "secondaryPreferred" | "nearest" | string;
675
+ readPreference?: 'primary' | 'primaryPreferred' | 'secondary' | 'secondaryPreferred' | 'nearest' | string;
674
676
  }
675
677
  /** withTransaction options */
676
678
  interface WithTransactionOptions {
@@ -679,7 +681,7 @@ interface WithTransactionOptions {
679
681
  /** Optional hook to observe fallback triggers */
680
682
  onFallback?: (error: Error) => void;
681
683
  /** MongoDB transaction options (readConcern, writeConcern, readPreference, maxCommitTimeMS) */
682
- transactionOptions?: mongoose$1.mongo.TransactionOptions;
684
+ transactionOptions?: _$mongoose.mongo.TransactionOptions;
683
685
  }
684
686
  /** Create operation options */
685
687
  interface CreateOptions {
@@ -726,7 +728,7 @@ type UpdateWithValidationResult<T> = {
726
728
  error: {
727
729
  code: number;
728
730
  message: string;
729
- violations?: ValidationResult["violations"];
731
+ violations?: ValidationResult['violations'];
730
732
  };
731
733
  };
732
734
  /** User context for operations */
@@ -777,13 +779,13 @@ interface RepositoryContext {
777
779
  /** Search query string */
778
780
  search?: string;
779
781
  /** Pagination mode */
780
- mode?: "offset" | "keyset";
782
+ mode?: 'offset' | 'keyset';
781
783
  /** Query hint */
782
784
  hint?: string | Record<string, 1 | -1>;
783
785
  /** Maximum execution time in milliseconds */
784
786
  maxTimeMS?: number;
785
787
  /** Count strategy for offset pagination */
786
- countStrategy?: "exact" | "estimated" | "none";
788
+ countStrategy?: 'exact' | 'estimated' | 'none';
787
789
  /** Whether this is a soft delete operation (set by softDeletePlugin) */
788
790
  softDeleted?: boolean;
789
791
  /** Include soft-deleted documents in queries */
@@ -836,11 +838,11 @@ interface RepositoryInstance {
836
838
  [key: string]: unknown;
837
839
  }
838
840
  /** Repository operation names */
839
- type RepositoryOperation = "create" | "createMany" | "update" | "updateMany" | "delete" | "deleteMany" | "getById" | "getByQuery" | "getAll" | "getOrCreate" | "count" | "exists" | "distinct" | "aggregate" | "aggregatePaginate" | "lookupPopulate" | "bulkWrite";
841
+ type RepositoryOperation = 'create' | 'createMany' | 'update' | 'updateMany' | 'delete' | 'deleteMany' | 'getById' | 'getByQuery' | 'getAll' | 'getOrCreate' | 'count' | 'exists' | 'distinct' | 'aggregate' | 'aggregatePaginate' | 'lookupPopulate' | 'bulkWrite';
840
842
  /** Event lifecycle phases */
841
- type EventPhase = "before" | "after" | "error";
843
+ type EventPhase = 'before' | 'after' | 'error';
842
844
  /** Repository event names (generated from template literals) */
843
- type RepositoryEvent = `${EventPhase}:${RepositoryOperation}` | "method:registered" | "error:hook";
845
+ type RepositoryEvent = `${EventPhase}:${RepositoryOperation}` | 'method:registered' | 'error:hook';
844
846
  /**
845
847
  * Type-safe event handler map
846
848
  *
@@ -890,7 +892,7 @@ interface SchemaBuilderOptions {
890
892
  /** Strict additional properties (default: false) */
891
893
  strictAdditionalProperties?: boolean;
892
894
  /** Date format: 'date' | 'datetime' */
893
- dateAs?: "date" | "datetime";
895
+ dateAs?: 'date' | 'datetime';
894
896
  /** Create schema options */
895
897
  create?: {
896
898
  /** Fields to omit from create schema */omitFields?: string[]; /** Override required status */
@@ -954,7 +956,7 @@ interface ValidatorDefinition {
954
956
  /** Validator name */
955
957
  name: string;
956
958
  /** Operations to apply validator to */
957
- operations?: Array<"create" | "createMany" | "update" | "delete">;
959
+ operations?: Array<'create' | 'createMany' | 'update' | 'delete'>;
958
960
  /** Validation function */
959
961
  validate: (context: RepositoryContext, repo?: RepositoryInstance) => void | Promise<void>;
960
962
  }
@@ -971,7 +973,7 @@ interface Logger {
971
973
  debug?(message: string, meta?: Record<string, unknown>): void;
972
974
  }
973
975
  /** Filter mode for soft delete queries */
974
- type SoftDeleteFilterMode = "null" | "exists";
976
+ type SoftDeleteFilterMode = 'null' | 'exists';
975
977
  /** Soft delete plugin options */
976
978
  interface SoftDeleteOptions {
977
979
  /** Field name for deletion timestamp (default: 'deletedAt') */