@classytic/mongokit 3.4.1 → 3.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.d.mts +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/{index-BuoZIZ15.d.mts → index-DHki2IxZ.d.mts} +1 -1
- package/dist/index.d.mts +39 -98
- package/dist/index.mjs +25 -1
- package/dist/{mongooseToJsonSchema-RX9YfJLu.d.mts → mongooseToJsonSchema-MTvR0gJv.d.mts} +1 -1
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/{types-COINbsdL.d.mts → types-nLhnjmdE.d.mts} +100 -34
- package/dist/utils/index.d.mts +2 -2
- package/dist/{validation-chain.plugin-BNoaKDOm.d.mts → validation-chain.plugin-C-IGsWHn.d.mts} +1 -1
- package/dist/{validation-chain.plugin-da3fOo8A.mjs → validation-chain.plugin-Cp5X5IZu.mjs} +1 -0
- package/package.json +1 -1
package/dist/actions/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_d_exports, i as delete_d_exports, n as update_d_exports, o as aggregate_d_exports, r as read_d_exports } from "../index-
|
|
1
|
+
import { a as create_d_exports, i as delete_d_exports, n as update_d_exports, o as aggregate_d_exports, r as read_d_exports } from "../index-DHki2IxZ.mjs";
|
|
2
2
|
export { aggregate_d_exports as aggregate, create_d_exports as create, delete_d_exports as deleteActions, read_d_exports as read, update_d_exports as update };
|
package/dist/ai/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as ReadPreferenceType, At as LookupOptions, D as GroupResult, V as ObjectId, W as OperationOptions, Z as PopulateSpec, _t as UpdateOptions, a as AnyDocument, b as DeleteResult, g as CreateOptions, gt as UpdateManyResult, pt as SortSpec, st as SelectSpec, vt as UpdateWithValidationResult, z as MinMaxResult } from "./types-nLhnjmdE.mjs";
|
|
2
2
|
import { ClientSession, Model, PipelineStage } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/actions/aggregate.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { t as index_d_exports } from "./index-
|
|
1
|
+
import { $ as ReadPreferenceType, A as InferDocument, At as LookupOptions, B as NonNullableFields, C as EventPayload, Ct as WithPlugins, D as GroupResult, Dt as IRequestContext, E as FieldRules, Et as IControllerResponse, F as KeysetPaginationResult, G as PaginationConfig, H as OffsetPaginationOptions, I as Logger, J as Plugin, K as PaginationResult, L as LookupPopulateOptions, M as JsonSchema, N as KeysOfType, O as HookMode, Ot as IResponseFormatter, P as KeysetPaginationOptions, Q as ReadOptions, R as LookupPopulateResult, S as EventHandlers, St as ValidatorDefinition, T as FieldPreset, Tt as IController, U as OffsetPaginationResult, V as ObjectId, W as OperationOptions, X as PluginType, Y as PluginFunction, Z as PopulateSpec, _ as CrudSchemas, _t as UpdateOptions, a as AnyDocument, at as RequiredBy, b as DeleteResult, bt as ValidationChainOptions, c as CacheOperationOptions, ct as SessionOptions, d as CacheableOptions, dt as SoftDeleteRepository, et as RepositoryContext, f as CascadeOptions, ft as SortDirection, g as CreateOptions, gt as UpdateManyResult, h as CreateInput, ht as UpdateInput, i as AllPluginMethods, it as RepositoryOptions, j as InferRawDoc, k as HttpError, kt as LookupBuilder, l as CacheOptions, lt as SoftDeleteFilterMode, m as CollationOptions, mt as Strict, n as AggregatePaginationOptions, nt as RepositoryInstance, o as AnyModel, ot as SchemaBuilderOptions, p as CascadeRelation, pt as SortSpec, q as PartialBy, r as AggregatePaginationResult, rt as RepositoryOperation, s as CacheAdapter, st as SelectSpec, t as AggregateOptions, tt as RepositoryEvent, u as CacheStats, ut as SoftDeleteOptions, v as DecodedCursor, vt as UpdateWithValidationResult, w as EventPhase, wt as WithTransactionOptions, x as DocField, xt as ValidationResult, y as DeepPartial, yt as UserContext, z as MinMaxResult } from "./types-nLhnjmdE.mjs";
|
|
2
|
+
import { t as index_d_exports } from "./index-DHki2IxZ.mjs";
|
|
3
3
|
import { PaginationEngine } from "./pagination/PaginationEngine.mjs";
|
|
4
|
-
import { A as dateSequentialId, B as AuditEntry, C as elasticSearchPlugin, D as PrefixedIdOptions, E as IdGenerator, F as CacheMethods, G as AuditTrailOptions, H as AuditQueryOptions, I as cachePlugin, J as auditLogPlugin, K as AuditTrailQuery, L as BatchOperationsMethods, M as prefixedId, N as sequentialId, O as SequentialIdOptions, P as cascadePlugin, R as BulkWriteResult, S as ElasticSearchOptions, T as DateSequentialIdOptions, U as AuditQueryResult, V as AuditOperation, W as AuditTrailMethods, X as aggregateHelpersPlugin, Y as AggregateHelpersMethods, _ as MongoOperationsMethods, a as uniqueField, b as methodRegistryPlugin, c as SubdocumentMethods, d as softDeletePlugin, f as ObservabilityOptions, g as multiTenantPlugin, h as MultiTenantOptions, i as requireField, j as getNextSequence, k as customIdPlugin, l as subdocumentPlugin, m as observabilityPlugin, n as blockIf, o as validationChainPlugin, p as OperationMetric, q as auditTrailPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as SoftDeleteMethods, v as mongoOperationsPlugin, w as CustomIdOptions, x as fieldFilterPlugin, z as batchOperationsPlugin } from "./validation-chain.plugin-
|
|
5
|
-
import { a as isFieldUpdateAllowed, c as configureLogger, d as getFieldsForUser, f as getMongooseProjection, i as getSystemManagedFields, l as createFieldPreset, m as parseDuplicateKeyError, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as createError, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as filterResponseData } from "./mongooseToJsonSchema-
|
|
4
|
+
import { A as dateSequentialId, B as AuditEntry, C as elasticSearchPlugin, D as PrefixedIdOptions, E as IdGenerator, F as CacheMethods, G as AuditTrailOptions, H as AuditQueryOptions, I as cachePlugin, J as auditLogPlugin, K as AuditTrailQuery, L as BatchOperationsMethods, M as prefixedId, N as sequentialId, O as SequentialIdOptions, P as cascadePlugin, R as BulkWriteResult, S as ElasticSearchOptions, T as DateSequentialIdOptions, U as AuditQueryResult, V as AuditOperation, W as AuditTrailMethods, X as aggregateHelpersPlugin, Y as AggregateHelpersMethods, _ as MongoOperationsMethods, a as uniqueField, b as methodRegistryPlugin, c as SubdocumentMethods, d as softDeletePlugin, f as ObservabilityOptions, g as multiTenantPlugin, h as MultiTenantOptions, i as requireField, j as getNextSequence, k as customIdPlugin, l as subdocumentPlugin, m as observabilityPlugin, n as blockIf, o as validationChainPlugin, p as OperationMetric, q as auditTrailPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as SoftDeleteMethods, v as mongoOperationsPlugin, w as CustomIdOptions, x as fieldFilterPlugin, z as batchOperationsPlugin } from "./validation-chain.plugin-C-IGsWHn.mjs";
|
|
5
|
+
import { a as isFieldUpdateAllowed, c as configureLogger, d as getFieldsForUser, f as getMongooseProjection, i as getSystemManagedFields, l as createFieldPreset, m as parseDuplicateKeyError, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as createError, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as filterResponseData } from "./mongooseToJsonSchema-MTvR0gJv.mjs";
|
|
6
6
|
import * as _$mongoose from "mongoose";
|
|
7
7
|
import { ClientSession, Expression, Model, PipelineStage, PopulateOptions } from "mongoose";
|
|
8
8
|
|
|
@@ -554,6 +554,24 @@ declare class QueryParser {
|
|
|
554
554
|
*/
|
|
555
555
|
private readonly dangerousRegexPatterns;
|
|
556
556
|
constructor(options?: QueryParserOptions);
|
|
557
|
+
/**
|
|
558
|
+
* Get the configured allowed filter fields.
|
|
559
|
+
* Returns `undefined` if no whitelist is set (all fields allowed).
|
|
560
|
+
*
|
|
561
|
+
* Used by Arc's MCP integration to auto-derive `filterableFields`
|
|
562
|
+
* from the QueryParser when `schemaOptions.filterableFields` is not set.
|
|
563
|
+
*/
|
|
564
|
+
get allowedFilterFields(): string[] | undefined;
|
|
565
|
+
/**
|
|
566
|
+
* Get the configured allowed sort fields.
|
|
567
|
+
* Returns `undefined` if no whitelist is set (all fields allowed).
|
|
568
|
+
*/
|
|
569
|
+
get allowedSortFields(): string[] | undefined;
|
|
570
|
+
/**
|
|
571
|
+
* Get the configured allowed operators.
|
|
572
|
+
* Returns `undefined` if no whitelist is set (all built-in operators allowed).
|
|
573
|
+
*/
|
|
574
|
+
get allowedOperators(): string[] | undefined;
|
|
557
575
|
/**
|
|
558
576
|
* Parse URL query parameters into MongoDB query format
|
|
559
577
|
*
|
|
@@ -749,7 +767,7 @@ declare const HOOK_PRIORITY: {
|
|
|
749
767
|
* Production-grade repository for MongoDB
|
|
750
768
|
* Event-driven, plugin-based, with smart pagination
|
|
751
769
|
*/
|
|
752
|
-
declare class Repository<TDoc =
|
|
770
|
+
declare class Repository<TDoc = unknown> {
|
|
753
771
|
readonly Model: Model<TDoc>;
|
|
754
772
|
readonly model: string;
|
|
755
773
|
readonly _hooks: Map<string, PrioritizedHook[]>;
|
|
@@ -771,13 +789,13 @@ declare class Repository<TDoc = any> {
|
|
|
771
789
|
* Lower priority numbers run first.
|
|
772
790
|
* Default: HOOK_PRIORITY.DEFAULT (500)
|
|
773
791
|
*/
|
|
774
|
-
on(event: string, listener: HookListener, options?: {
|
|
792
|
+
on(event: RepositoryEvent | (string & {}), listener: HookListener, options?: {
|
|
775
793
|
priority?: number;
|
|
776
794
|
}): this;
|
|
777
795
|
/**
|
|
778
796
|
* Remove a specific event listener
|
|
779
797
|
*/
|
|
780
|
-
off(event: string, listener: HookListener): this;
|
|
798
|
+
off(event: RepositoryEvent | (string & {}), listener: HookListener): this;
|
|
781
799
|
/**
|
|
782
800
|
* Remove all listeners for an event, or all listeners entirely
|
|
783
801
|
*/
|
|
@@ -795,44 +813,19 @@ declare class Repository<TDoc = any> {
|
|
|
795
813
|
/**
|
|
796
814
|
* Create single document
|
|
797
815
|
*/
|
|
798
|
-
create(data: Record<string, unknown>, options?:
|
|
799
|
-
session?: ClientSession;
|
|
800
|
-
}): Promise<TDoc>;
|
|
816
|
+
create(data: Record<string, unknown>, options?: CreateOptions): Promise<TDoc>;
|
|
801
817
|
/**
|
|
802
818
|
* Create multiple documents
|
|
803
819
|
*/
|
|
804
|
-
createMany(dataArray: Record<string, unknown>[], options?:
|
|
805
|
-
session?: ClientSession;
|
|
806
|
-
ordered?: boolean;
|
|
807
|
-
}): Promise<TDoc[]>;
|
|
820
|
+
createMany(dataArray: Record<string, unknown>[], options?: CreateOptions): Promise<TDoc[]>;
|
|
808
821
|
/**
|
|
809
822
|
* Get document by ID
|
|
810
823
|
*/
|
|
811
|
-
getById(id: string | ObjectId, options?:
|
|
812
|
-
select?: SelectSpec;
|
|
813
|
-
populate?: PopulateSpec;
|
|
814
|
-
populateOptions?: PopulateOptions[];
|
|
815
|
-
lean?: boolean;
|
|
816
|
-
session?: ClientSession;
|
|
817
|
-
throwOnNotFound?: boolean;
|
|
818
|
-
skipCache?: boolean;
|
|
819
|
-
cacheTtl?: number;
|
|
820
|
-
readPreference?: ReadPreferenceType;
|
|
821
|
-
}): Promise<TDoc | null>;
|
|
824
|
+
getById(id: string | ObjectId, options?: CacheableOptions): Promise<TDoc | null>;
|
|
822
825
|
/**
|
|
823
826
|
* Get single document by query
|
|
824
827
|
*/
|
|
825
|
-
getByQuery(query: Record<string, unknown>, options?:
|
|
826
|
-
select?: SelectSpec;
|
|
827
|
-
populate?: PopulateSpec;
|
|
828
|
-
populateOptions?: PopulateOptions[];
|
|
829
|
-
lean?: boolean;
|
|
830
|
-
session?: ClientSession;
|
|
831
|
-
throwOnNotFound?: boolean;
|
|
832
|
-
skipCache?: boolean;
|
|
833
|
-
cacheTtl?: number;
|
|
834
|
-
readPreference?: ReadPreferenceType;
|
|
835
|
-
}): Promise<TDoc | null>;
|
|
828
|
+
getByQuery(query: Record<string, unknown>, options?: CacheableOptions): Promise<TDoc | null>;
|
|
836
829
|
/**
|
|
837
830
|
* Unified pagination - auto-detects offset vs keyset based on params
|
|
838
831
|
*
|
|
@@ -876,39 +869,22 @@ declare class Repository<TDoc = any> {
|
|
|
876
869
|
populateOptions?: PopulateOptions[]; /** Collation for locale-aware string comparison */
|
|
877
870
|
collation?: CollationOptions; /** Lookup configurations for $lookup joins (from QueryParser or manual) */
|
|
878
871
|
lookups?: LookupOptions[];
|
|
879
|
-
}, options?:
|
|
880
|
-
select?: SelectSpec;
|
|
881
|
-
populate?: PopulateSpec;
|
|
882
|
-
populateOptions?: PopulateOptions[];
|
|
883
|
-
lean?: boolean;
|
|
884
|
-
session?: ClientSession;
|
|
885
|
-
skipCache?: boolean;
|
|
886
|
-
cacheTtl?: number;
|
|
887
|
-
readPreference?: ReadPreferenceType;
|
|
888
|
-
}): Promise<OffsetPaginationResult<TDoc> | KeysetPaginationResult<TDoc>>;
|
|
872
|
+
}, options?: CacheableOptions): Promise<OffsetPaginationResult<TDoc> | KeysetPaginationResult<TDoc>>;
|
|
889
873
|
/**
|
|
890
874
|
* Get or create document
|
|
891
875
|
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
892
876
|
*/
|
|
893
|
-
getOrCreate(query: Record<string, unknown>, createData: Record<string, unknown>, options?:
|
|
894
|
-
session?: ClientSession;
|
|
895
|
-
}): Promise<TDoc | null>;
|
|
877
|
+
getOrCreate(query: Record<string, unknown>, createData: Record<string, unknown>, options?: SessionOptions): Promise<TDoc | null>;
|
|
896
878
|
/**
|
|
897
879
|
* Count documents
|
|
898
880
|
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
899
881
|
*/
|
|
900
|
-
count(query?: Record<string, unknown>, options?:
|
|
901
|
-
session?: ClientSession;
|
|
902
|
-
readPreference?: ReadPreferenceType;
|
|
903
|
-
}): Promise<number>;
|
|
882
|
+
count(query?: Record<string, unknown>, options?: ReadOptions): Promise<number>;
|
|
904
883
|
/**
|
|
905
884
|
* Check if document exists
|
|
906
885
|
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
907
886
|
*/
|
|
908
|
-
exists(query: Record<string, unknown>, options?: {
|
|
909
|
-
session?: ClientSession;
|
|
910
|
-
readPreference?: ReadPreferenceType;
|
|
911
|
-
}): Promise<{
|
|
887
|
+
exists(query: Record<string, unknown>, options?: ReadOptions): Promise<{
|
|
912
888
|
_id: unknown;
|
|
913
889
|
} | null>;
|
|
914
890
|
/**
|
|
@@ -918,9 +894,7 @@ declare class Repository<TDoc = any> {
|
|
|
918
894
|
/**
|
|
919
895
|
* Delete document by ID
|
|
920
896
|
*/
|
|
921
|
-
delete(id: string | ObjectId, options?:
|
|
922
|
-
session?: ClientSession;
|
|
923
|
-
}): Promise<DeleteResult>;
|
|
897
|
+
delete(id: string | ObjectId, options?: SessionOptions): Promise<DeleteResult>;
|
|
924
898
|
/**
|
|
925
899
|
* Execute aggregation pipeline
|
|
926
900
|
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
@@ -928,18 +902,7 @@ declare class Repository<TDoc = any> {
|
|
|
928
902
|
* @param pipeline - Aggregation pipeline stages
|
|
929
903
|
* @param options - Aggregation options including governance controls
|
|
930
904
|
*/
|
|
931
|
-
aggregate<TResult = unknown>(pipeline: PipelineStage[], options?:
|
|
932
|
-
session?: ClientSession;
|
|
933
|
-
allowDiskUse?: boolean;
|
|
934
|
-
comment?: string;
|
|
935
|
-
readPreference?: ReadPreferenceType;
|
|
936
|
-
maxTimeMS?: number;
|
|
937
|
-
readConcern?: {
|
|
938
|
-
level: string;
|
|
939
|
-
};
|
|
940
|
-
collation?: Record<string, unknown>;
|
|
941
|
-
maxPipelineStages?: number;
|
|
942
|
-
}): Promise<TResult[]>;
|
|
905
|
+
aggregate<TResult = unknown>(pipeline: PipelineStage[], options?: AggregateOptions): Promise<TResult[]>;
|
|
943
906
|
/**
|
|
944
907
|
* Aggregate pipeline with pagination
|
|
945
908
|
* Best for: Complex queries, grouping, joins
|
|
@@ -952,10 +915,7 @@ declare class Repository<TDoc = any> {
|
|
|
952
915
|
* Get distinct values
|
|
953
916
|
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
954
917
|
*/
|
|
955
|
-
distinct<T = unknown>(field: string, query?: Record<string, unknown>, options?:
|
|
956
|
-
session?: ClientSession;
|
|
957
|
-
readPreference?: ReadPreferenceType;
|
|
958
|
-
}): Promise<T[]>;
|
|
918
|
+
distinct<T = unknown>(field: string, query?: Record<string, unknown>, options?: ReadOptions): Promise<T[]>;
|
|
959
919
|
/**
|
|
960
920
|
* Query with custom field lookups ($lookup)
|
|
961
921
|
* Best for: Joins on slugs, SKUs, codes, or other indexed custom fields
|
|
@@ -980,26 +940,7 @@ declare class Repository<TDoc = any> {
|
|
|
980
940
|
* });
|
|
981
941
|
* ```
|
|
982
942
|
*/
|
|
983
|
-
lookupPopulate(options:
|
|
984
|
-
filters?: Record<string, unknown>;
|
|
985
|
-
lookups: LookupOptions[];
|
|
986
|
-
sort?: SortSpec | string;
|
|
987
|
-
page?: number;
|
|
988
|
-
after?: string;
|
|
989
|
-
limit?: number;
|
|
990
|
-
select?: SelectSpec;
|
|
991
|
-
session?: ClientSession;
|
|
992
|
-
readPreference?: ReadPreferenceType;
|
|
993
|
-
collation?: CollationOptions;
|
|
994
|
-
countStrategy?: 'exact' | 'estimated' | 'none';
|
|
995
|
-
}): Promise<{
|
|
996
|
-
data: TDoc[];
|
|
997
|
-
total?: number;
|
|
998
|
-
page?: number;
|
|
999
|
-
limit?: number;
|
|
1000
|
-
next?: string | null;
|
|
1001
|
-
hasMore?: boolean;
|
|
1002
|
-
}>;
|
|
943
|
+
lookupPopulate(options: LookupPopulateOptions): Promise<LookupPopulateResult<TDoc>>;
|
|
1003
944
|
/**
|
|
1004
945
|
* Create an aggregation builder for this model
|
|
1005
946
|
* Useful for building complex custom aggregations
|
|
@@ -1082,7 +1023,7 @@ declare class Repository<TDoc = any> {
|
|
|
1082
1023
|
* 3. OBSERVABILITY (300) — audit logging, metrics
|
|
1083
1024
|
* 4. DEFAULT (500) — user-registered hooks
|
|
1084
1025
|
*/
|
|
1085
|
-
_buildContext(operation: string, options: Record<string, unknown>): Promise<RepositoryContext>;
|
|
1026
|
+
_buildContext(operation: string, options: Record<string, unknown> | object): Promise<RepositoryContext>;
|
|
1086
1027
|
/**
|
|
1087
1028
|
* Parse sort string or object
|
|
1088
1029
|
*/
|
|
@@ -1110,4 +1051,4 @@ declare class Repository<TDoc = any> {
|
|
|
1110
1051
|
*/
|
|
1111
1052
|
declare function createRepository<TDoc>(Model: _$mongoose.Model<TDoc, any, any, any>, plugins?: PluginType[], paginationConfig?: PaginationConfig, options?: RepositoryOptions): Repository<TDoc>;
|
|
1112
1053
|
//#endregion
|
|
1113
|
-
export { type AggregateHelpersMethods, type AggregatePaginationOptions, type AggregatePaginationResult, AggregationBuilder, type AllPluginMethods, type AnyDocument, type AnyModel, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheMethods, type CacheOperationOptions, type CacheOptions, type CacheStats, type CascadeOptions, type CascadeRelation, type CollationOptions, type CreateInput, type CreateOptions, type CrudSchemas, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DeleteResult, type ElasticSearchOptions, type EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldRules, type FilterQuery, type GroupResult, HOOK_PRIORITY, type HookMode, type HttpError, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, type InferDocument, type InferRawDoc, type JsonSchema, type KeysOfType, type KeysetPaginationOptions, type KeysetPaginationResult, type Logger, LookupBuilder, type LookupOptions, type MinMaxResult, type MongoOperationsMethods, type MultiTenantOptions, type NonNullableFields, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OffsetPaginationResult, type OperationMetric, type OperationOptions, type PaginationConfig, PaginationEngine, type PaginationResult, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, QueryParser, type QueryParserOptions, type ReadPreferenceType, Repository, Repository as default, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RequiredBy, type SchemaBuilderOptions, type SearchMode, type SelectSpec, type SequentialIdOptions, type SoftDeleteFilterMode, type SoftDeleteMethods, type SoftDeleteOptions, type SoftDeleteRepository, type SortDirection, type SortSpec, type Strict, type SubdocumentMethods, type UpdateInput, type UpdateManyResult, type UpdateOptions, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidationResult, type ValidatorDefinition, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, configureLogger, createError, createFieldPreset, createMemoryCache, createRepository, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getImmutableFields, getMongooseProjection, getNextSequence, getSystemManagedFields, immutableField, isFieldUpdateAllowed, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, parseDuplicateKeyError, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validateUpdateBody, validationChainPlugin };
|
|
1054
|
+
export { type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, type AggregatePaginationResult, AggregationBuilder, type AllPluginMethods, type AnyDocument, type AnyModel, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheMethods, type CacheOperationOptions, type CacheOptions, type CacheStats, type CacheableOptions, type CascadeOptions, type CascadeRelation, type CollationOptions, type CreateInput, type CreateOptions, type CrudSchemas, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DeleteResult, type DocField, type ElasticSearchOptions, type EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldRules, type FilterQuery, type GroupResult, HOOK_PRIORITY, type HookMode, type HttpError, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, type InferDocument, type InferRawDoc, type JsonSchema, type KeysOfType, type KeysetPaginationOptions, type KeysetPaginationResult, type Logger, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, type MinMaxResult, type MongoOperationsMethods, type MultiTenantOptions, type NonNullableFields, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OffsetPaginationResult, type OperationMetric, type OperationOptions, type PaginationConfig, PaginationEngine, type PaginationResult, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, QueryParser, type QueryParserOptions, type ReadOptions, type ReadPreferenceType, Repository, Repository as default, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RequiredBy, type SchemaBuilderOptions, type SearchMode, type SelectSpec, type SequentialIdOptions, type SessionOptions, type SoftDeleteFilterMode, type SoftDeleteMethods, type SoftDeleteOptions, type SoftDeleteRepository, type SortDirection, type SortSpec, type Strict, type SubdocumentMethods, type UpdateInput, type UpdateManyResult, type UpdateOptions, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidationResult, type ValidatorDefinition, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, configureLogger, createError, createFieldPreset, createMemoryCache, createRepository, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getImmutableFields, getMongooseProjection, getNextSequence, getSystemManagedFields, immutableField, isFieldUpdateAllowed, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, parseDuplicateKeyError, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validateUpdateBody, validationChainPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { a as warn, n as parseDuplicateKeyError, r as configureLogger, t as crea
|
|
|
2
2
|
import { _ as LookupBuilder } from "./update-DGKMmBgG.mjs";
|
|
3
3
|
import { t as actions_exports } from "./actions/index.mjs";
|
|
4
4
|
import { t as PaginationEngine } from "./PaginationEngine-nY04eGUM.mjs";
|
|
5
|
-
import { A as aggregateHelpersPlugin, C as HOOK_PRIORITY, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as cachePlugin, T as AggregationBuilder, _ as dateSequentialId, a as uniqueField, b as sequentialId, c as subdocumentPlugin, d as multiTenantPlugin, f as mongoOperationsPlugin, g as customIdPlugin, h as elasticSearchPlugin, i as requireField, k as auditLogPlugin, l as softDeletePlugin, m as fieldFilterPlugin, n as blockIf, o as validationChainPlugin, p as methodRegistryPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as observabilityPlugin, v as getNextSequence, w as Repository, x as cascadePlugin, y as prefixedId } from "./validation-chain.plugin-
|
|
5
|
+
import { A as aggregateHelpersPlugin, C as HOOK_PRIORITY, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as cachePlugin, T as AggregationBuilder, _ as dateSequentialId, a as uniqueField, b as sequentialId, c as subdocumentPlugin, d as multiTenantPlugin, f as mongoOperationsPlugin, g as customIdPlugin, h as elasticSearchPlugin, i as requireField, k as auditLogPlugin, l as softDeletePlugin, m as fieldFilterPlugin, n as blockIf, o as validationChainPlugin, p as methodRegistryPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as observabilityPlugin, v as getNextSequence, w as Repository, x as cascadePlugin, y as prefixedId } from "./validation-chain.plugin-Cp5X5IZu.mjs";
|
|
6
6
|
import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-reyDRzXf.mjs";
|
|
7
7
|
import { a as isFieldUpdateAllowed, i as getSystemManagedFields, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-B6Qyl8BK.mjs";
|
|
8
8
|
import mongoose from "mongoose";
|
|
@@ -69,6 +69,30 @@ var QueryParser = class {
|
|
|
69
69
|
];
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
+
* Get the configured allowed filter fields.
|
|
73
|
+
* Returns `undefined` if no whitelist is set (all fields allowed).
|
|
74
|
+
*
|
|
75
|
+
* Used by Arc's MCP integration to auto-derive `filterableFields`
|
|
76
|
+
* from the QueryParser when `schemaOptions.filterableFields` is not set.
|
|
77
|
+
*/
|
|
78
|
+
get allowedFilterFields() {
|
|
79
|
+
return this.options.allowedFilterFields;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the configured allowed sort fields.
|
|
83
|
+
* Returns `undefined` if no whitelist is set (all fields allowed).
|
|
84
|
+
*/
|
|
85
|
+
get allowedSortFields() {
|
|
86
|
+
return this.options.allowedSortFields;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Get the configured allowed operators.
|
|
90
|
+
* Returns `undefined` if no whitelist is set (all built-in operators allowed).
|
|
91
|
+
*/
|
|
92
|
+
get allowedOperators() {
|
|
93
|
+
return this.options.allowedOperators;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
72
96
|
* Parse URL query parameters into MongoDB query format
|
|
73
97
|
*
|
|
74
98
|
* @example
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as FieldPreset, _ as CrudSchemas, k as HttpError, ot as SchemaBuilderOptions, s as CacheAdapter, xt as ValidationResult, yt as UserContext } from "./types-nLhnjmdE.mjs";
|
|
2
2
|
import mongoose, { Schema } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/error.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as KeysetPaginationResult, G as PaginationConfig, H as OffsetPaginationOptions, P as KeysetPaginationOptions, U as OffsetPaginationResult, a as AnyDocument, n as AggregatePaginationOptions, r as AggregatePaginationResult } from "../types-nLhnjmdE.mjs";
|
|
2
2
|
import { Model } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/pagination/PaginationEngine.d.ts
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as dateSequentialId, B as AuditEntry, C as elasticSearchPlugin, D as PrefixedIdOptions, E as IdGenerator, F as CacheMethods, G as AuditTrailOptions, H as AuditQueryOptions, I as cachePlugin, J as auditLogPlugin, K as AuditTrailQuery, L as BatchOperationsMethods, M as prefixedId, N as sequentialId, O as SequentialIdOptions, P as cascadePlugin, S as ElasticSearchOptions, T as DateSequentialIdOptions, U as AuditQueryResult, V as AuditOperation, W as AuditTrailMethods, X as aggregateHelpersPlugin, Y as AggregateHelpersMethods, _ as MongoOperationsMethods, a as uniqueField, b as methodRegistryPlugin, c as SubdocumentMethods, d as softDeletePlugin, f as ObservabilityOptions, g as multiTenantPlugin, h as MultiTenantOptions, i as requireField, j as getNextSequence, k as customIdPlugin, l as subdocumentPlugin, m as observabilityPlugin, n as blockIf, o as validationChainPlugin, p as OperationMetric, q as auditTrailPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as SoftDeleteMethods, v as mongoOperationsPlugin, w as CustomIdOptions, x as fieldFilterPlugin, y as MethodRegistryRepository, z as batchOperationsPlugin } from "../validation-chain.plugin-
|
|
1
|
+
import { A as dateSequentialId, B as AuditEntry, C as elasticSearchPlugin, D as PrefixedIdOptions, E as IdGenerator, F as CacheMethods, G as AuditTrailOptions, H as AuditQueryOptions, I as cachePlugin, J as auditLogPlugin, K as AuditTrailQuery, L as BatchOperationsMethods, M as prefixedId, N as sequentialId, O as SequentialIdOptions, P as cascadePlugin, S as ElasticSearchOptions, T as DateSequentialIdOptions, U as AuditQueryResult, V as AuditOperation, W as AuditTrailMethods, X as aggregateHelpersPlugin, Y as AggregateHelpersMethods, _ as MongoOperationsMethods, a as uniqueField, b as methodRegistryPlugin, c as SubdocumentMethods, d as softDeletePlugin, f as ObservabilityOptions, g as multiTenantPlugin, h as MultiTenantOptions, i as requireField, j as getNextSequence, k as customIdPlugin, l as subdocumentPlugin, m as observabilityPlugin, n as blockIf, o as validationChainPlugin, p as OperationMetric, q as auditTrailPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as SoftDeleteMethods, v as mongoOperationsPlugin, w as CustomIdOptions, x as fieldFilterPlugin, y as MethodRegistryRepository, z as batchOperationsPlugin } from "../validation-chain.plugin-C-IGsWHn.mjs";
|
|
2
2
|
export { type AggregateHelpersMethods, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type CacheMethods, type CustomIdOptions, type DateSequentialIdOptions, type ElasticSearchOptions, type IdGenerator, type MethodRegistryRepository, type MongoOperationsMethods, type MultiTenantOptions, type ObservabilityOptions, type OperationMetric, type PrefixedIdOptions, type SequentialIdOptions, type SoftDeleteMethods, type SubdocumentMethods, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as aggregateHelpersPlugin, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as cachePlugin, _ as dateSequentialId, a as uniqueField, b as sequentialId, c as subdocumentPlugin, d as multiTenantPlugin, f as mongoOperationsPlugin, g as customIdPlugin, h as elasticSearchPlugin, i as requireField, k as auditLogPlugin, l as softDeletePlugin, m as fieldFilterPlugin, n as blockIf, o as validationChainPlugin, p as methodRegistryPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as observabilityPlugin, v as getNextSequence, x as cascadePlugin, y as prefixedId } from "../validation-chain.plugin-
|
|
1
|
+
import { A as aggregateHelpersPlugin, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as cachePlugin, _ as dateSequentialId, a as uniqueField, b as sequentialId, c as subdocumentPlugin, d as multiTenantPlugin, f as mongoOperationsPlugin, g as customIdPlugin, h as elasticSearchPlugin, i as requireField, k as auditLogPlugin, l as softDeletePlugin, m as fieldFilterPlugin, n as blockIf, o as validationChainPlugin, p as methodRegistryPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as observabilityPlugin, v as getNextSequence, x as cascadePlugin, y as prefixedId } from "../validation-chain.plugin-Cp5X5IZu.mjs";
|
|
2
2
|
export { AuditTrailQuery, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
|
|
@@ -677,22 +677,37 @@ interface AggregatePaginationResult<T = unknown> {
|
|
|
677
677
|
}
|
|
678
678
|
/** Union type for all pagination results */
|
|
679
679
|
type PaginationResult<T = unknown> = OffsetPaginationResult<T> | KeysetPaginationResult<T> | AggregatePaginationResult<T>;
|
|
680
|
-
/**
|
|
681
|
-
interface
|
|
680
|
+
/** Session-only options — shared base for lightweight operations */
|
|
681
|
+
interface SessionOptions {
|
|
682
682
|
/** MongoDB session for transactions */
|
|
683
683
|
session?: ClientSession;
|
|
684
|
+
}
|
|
685
|
+
/** Read options — session + readPreference for read-only operations */
|
|
686
|
+
interface ReadOptions extends SessionOptions {
|
|
687
|
+
/** Read preference for replica sets (e.g. 'secondaryPreferred') */
|
|
688
|
+
readPreference?: ReadPreferenceType;
|
|
689
|
+
}
|
|
690
|
+
/** Repository operation options */
|
|
691
|
+
interface OperationOptions extends ReadOptions {
|
|
684
692
|
/** Fields to select */
|
|
685
693
|
select?: SelectSpec;
|
|
686
694
|
/** Fields to populate */
|
|
687
695
|
populate?: PopulateSpec;
|
|
696
|
+
/** Advanced populate options (from QueryParser or Arc's BaseController) */
|
|
697
|
+
populateOptions?: PopulateOptions[];
|
|
688
698
|
/** Return plain JavaScript objects */
|
|
689
699
|
lean?: boolean;
|
|
690
700
|
/** Throw error if document not found (default: true) */
|
|
691
701
|
throwOnNotFound?: boolean;
|
|
692
702
|
/** Additional query filters (e.g., for soft delete) */
|
|
693
703
|
query?: Record<string, unknown>;
|
|
694
|
-
|
|
695
|
-
|
|
704
|
+
}
|
|
705
|
+
/** Cache-aware operation options — extends OperationOptions with cache controls */
|
|
706
|
+
interface CacheableOptions extends OperationOptions {
|
|
707
|
+
/** Skip cache for this operation (read from DB directly) */
|
|
708
|
+
skipCache?: boolean;
|
|
709
|
+
/** Custom TTL for this operation in seconds */
|
|
710
|
+
cacheTtl?: number;
|
|
696
711
|
}
|
|
697
712
|
/** withTransaction options */
|
|
698
713
|
interface WithTransactionOptions {
|
|
@@ -704,9 +719,7 @@ interface WithTransactionOptions {
|
|
|
704
719
|
transactionOptions?: _$mongoose.mongo.TransactionOptions;
|
|
705
720
|
}
|
|
706
721
|
/** Create operation options */
|
|
707
|
-
interface CreateOptions {
|
|
708
|
-
/** MongoDB session for transactions */
|
|
709
|
-
session?: ClientSession;
|
|
722
|
+
interface CreateOptions extends SessionOptions {
|
|
710
723
|
/** Keep insertion order on error (default: true) */
|
|
711
724
|
ordered?: boolean;
|
|
712
725
|
}
|
|
@@ -717,6 +730,53 @@ interface UpdateOptions extends OperationOptions {
|
|
|
717
730
|
/** Array filters for positional operator $[<identifier>] updates */
|
|
718
731
|
arrayFilters?: Record<string, unknown>[];
|
|
719
732
|
}
|
|
733
|
+
/** Aggregate operation options */
|
|
734
|
+
interface AggregateOptions extends ReadOptions {
|
|
735
|
+
/** Allow aggregation to use disk for large sorts/groups */
|
|
736
|
+
allowDiskUse?: boolean;
|
|
737
|
+
/** Comment for profiler/logs */
|
|
738
|
+
comment?: string;
|
|
739
|
+
/** Maximum execution time in milliseconds */
|
|
740
|
+
maxTimeMS?: number;
|
|
741
|
+
/** Read concern level */
|
|
742
|
+
readConcern?: {
|
|
743
|
+
level: string;
|
|
744
|
+
};
|
|
745
|
+
/** Collation for locale-aware string comparison */
|
|
746
|
+
collation?: CollationOptions;
|
|
747
|
+
/** Maximum allowed pipeline stages (governance) */
|
|
748
|
+
maxPipelineStages?: number;
|
|
749
|
+
}
|
|
750
|
+
/** Lookup populate options */
|
|
751
|
+
interface LookupPopulateOptions extends ReadOptions {
|
|
752
|
+
/** MongoDB query filters */
|
|
753
|
+
filters?: Record<string, unknown>;
|
|
754
|
+
/** Lookup configurations for $lookup joins */
|
|
755
|
+
lookups: LookupOptions[];
|
|
756
|
+
/** Sort specification */
|
|
757
|
+
sort?: SortSpec | string;
|
|
758
|
+
/** Page number (offset mode, 1-indexed) */
|
|
759
|
+
page?: number;
|
|
760
|
+
/** Cursor token for next page (keyset mode) */
|
|
761
|
+
after?: string;
|
|
762
|
+
/** Number of documents per page */
|
|
763
|
+
limit?: number;
|
|
764
|
+
/** Fields to select */
|
|
765
|
+
select?: SelectSpec;
|
|
766
|
+
/** Collation for locale-aware string comparison */
|
|
767
|
+
collation?: CollationOptions;
|
|
768
|
+
/** Count strategy for offset pagination */
|
|
769
|
+
countStrategy?: 'exact' | 'estimated' | 'none';
|
|
770
|
+
}
|
|
771
|
+
/** Lookup populate result */
|
|
772
|
+
interface LookupPopulateResult<T = unknown> {
|
|
773
|
+
data: T[];
|
|
774
|
+
total: number;
|
|
775
|
+
page?: number;
|
|
776
|
+
limit: number;
|
|
777
|
+
next?: string | null;
|
|
778
|
+
hasMore?: boolean;
|
|
779
|
+
}
|
|
720
780
|
/** Delete result */
|
|
721
781
|
interface DeleteResult {
|
|
722
782
|
success: boolean;
|
|
@@ -846,16 +906,16 @@ interface RepositoryInstance {
|
|
|
846
906
|
_hooks: Map<string, PrioritizedHook[]>;
|
|
847
907
|
_pagination: unknown;
|
|
848
908
|
use(plugin: PluginType): this;
|
|
849
|
-
on(event: string, listener: (data: any) => void | Promise<void>, options?: {
|
|
909
|
+
on(event: RepositoryEvent | (string & {}), listener: (data: any) => void | Promise<void>, options?: {
|
|
850
910
|
priority?: number;
|
|
851
911
|
}): this;
|
|
852
|
-
off(event: string, listener: (data: any) => void | Promise<void>): this;
|
|
912
|
+
off(event: RepositoryEvent | (string & {}), listener: (data: any) => void | Promise<void>): this;
|
|
853
913
|
removeAllListeners(event?: string): this;
|
|
854
914
|
emit(event: string, data: unknown): void;
|
|
855
915
|
emitAsync(event: string, data: unknown): Promise<void>;
|
|
856
916
|
registerMethod?(name: string, fn: (...args: any[]) => any): void;
|
|
857
917
|
hasMethod?(name: string): boolean;
|
|
858
|
-
_buildContext(operation: string, options: Record<string, unknown>): Promise<RepositoryContext>;
|
|
918
|
+
_buildContext(operation: string, options: Record<string, unknown> | object): Promise<RepositoryContext>;
|
|
859
919
|
_handleError(error: Error): HttpError;
|
|
860
920
|
update(id: string | ObjectId, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<unknown>;
|
|
861
921
|
aggregate(pipeline: PipelineStage[], options?: Record<string, unknown>): Promise<unknown[]>;
|
|
@@ -1028,7 +1088,7 @@ interface SoftDeleteOptions {
|
|
|
1028
1088
|
ttlDays?: number;
|
|
1029
1089
|
}
|
|
1030
1090
|
/** Repository with soft delete methods */
|
|
1031
|
-
interface SoftDeleteRepository {
|
|
1091
|
+
interface SoftDeleteRepository<TDoc = unknown> {
|
|
1032
1092
|
/**
|
|
1033
1093
|
* Restore a soft-deleted document by setting deletedAt to null
|
|
1034
1094
|
* @param id - Document ID to restore
|
|
@@ -1037,7 +1097,7 @@ interface SoftDeleteRepository {
|
|
|
1037
1097
|
*/
|
|
1038
1098
|
restore(id: string | ObjectId, options?: {
|
|
1039
1099
|
session?: ClientSession;
|
|
1040
|
-
}): Promise<
|
|
1100
|
+
}): Promise<TDoc>;
|
|
1041
1101
|
/**
|
|
1042
1102
|
* Get all soft-deleted documents
|
|
1043
1103
|
* @param params - Query parameters (filters, pagination, etc.)
|
|
@@ -1054,7 +1114,7 @@ interface SoftDeleteRepository {
|
|
|
1054
1114
|
populate?: PopulateSpec;
|
|
1055
1115
|
lean?: boolean;
|
|
1056
1116
|
session?: ClientSession;
|
|
1057
|
-
}): Promise<OffsetPaginationResult<
|
|
1117
|
+
}): Promise<OffsetPaginationResult<TDoc>>;
|
|
1058
1118
|
}
|
|
1059
1119
|
/** Group result */
|
|
1060
1120
|
interface GroupResult {
|
|
@@ -1187,19 +1247,25 @@ interface HttpError extends Error {
|
|
|
1187
1247
|
* } from '@classytic/mongokit';
|
|
1188
1248
|
* ```
|
|
1189
1249
|
*/
|
|
1250
|
+
/**
|
|
1251
|
+
* Extract string keys from a document type, with `string` fallback for untyped usage.
|
|
1252
|
+
* Provides autocomplete for known fields while still accepting arbitrary strings
|
|
1253
|
+
* (e.g. for nested paths like 'address.city').
|
|
1254
|
+
*/
|
|
1255
|
+
type DocField<TDoc> = (keyof TDoc & string) | (string & {});
|
|
1190
1256
|
type AllPluginMethods<TDoc> = {
|
|
1191
1257
|
upsert(query: Record<string, unknown>, data: Record<string, unknown>, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1192
|
-
increment(id: string | ObjectId, field:
|
|
1193
|
-
decrement(id: string | ObjectId, field:
|
|
1194
|
-
pushToArray(id: string | ObjectId, field:
|
|
1195
|
-
pullFromArray(id: string | ObjectId, field:
|
|
1196
|
-
addToSet(id: string | ObjectId, field:
|
|
1197
|
-
setField(id: string | ObjectId, field:
|
|
1198
|
-
unsetField(id: string | ObjectId, fields:
|
|
1199
|
-
renameField(id: string | ObjectId, oldName:
|
|
1200
|
-
multiplyField(id: string | ObjectId, field:
|
|
1201
|
-
setMin(id: string | ObjectId, field:
|
|
1202
|
-
setMax(id: string | ObjectId, field:
|
|
1258
|
+
increment(id: string | ObjectId, field: DocField<TDoc>, value?: number, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1259
|
+
decrement(id: string | ObjectId, field: DocField<TDoc>, value?: number, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1260
|
+
pushToArray(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1261
|
+
pullFromArray(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1262
|
+
addToSet(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1263
|
+
setField(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1264
|
+
unsetField(id: string | ObjectId, fields: DocField<TDoc> | DocField<TDoc>[], options?: Record<string, unknown>): Promise<TDoc>;
|
|
1265
|
+
renameField(id: string | ObjectId, oldName: DocField<TDoc>, newName: string, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1266
|
+
multiplyField(id: string | ObjectId, field: DocField<TDoc>, multiplier: number, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1267
|
+
setMin(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1268
|
+
setMax(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1203
1269
|
atomicUpdate(id: string | ObjectId, operators: Record<string, Record<string, unknown>>, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1204
1270
|
updateMany(query: Record<string, unknown>, data: Record<string, unknown>, options?: {
|
|
1205
1271
|
session?: ClientSession;
|
|
@@ -1228,26 +1294,26 @@ type AllPluginMethods<TDoc> = {
|
|
|
1228
1294
|
insertedIds: Record<number, unknown>;
|
|
1229
1295
|
upsertedIds: Record<number, unknown>;
|
|
1230
1296
|
}>;
|
|
1231
|
-
groupBy(field:
|
|
1297
|
+
groupBy(field: DocField<TDoc>, options?: {
|
|
1232
1298
|
limit?: number;
|
|
1233
1299
|
session?: unknown;
|
|
1234
1300
|
}): Promise<Array<{
|
|
1235
1301
|
_id: unknown;
|
|
1236
1302
|
count: number;
|
|
1237
1303
|
}>>;
|
|
1238
|
-
sum(field:
|
|
1239
|
-
average(field:
|
|
1240
|
-
min(field:
|
|
1241
|
-
max(field:
|
|
1242
|
-
addSubdocument(parentId: string | ObjectId, arrayPath:
|
|
1243
|
-
getSubdocument(parentId: string | ObjectId, arrayPath:
|
|
1304
|
+
sum(field: DocField<TDoc>, query?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
1305
|
+
average(field: DocField<TDoc>, query?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
1306
|
+
min(field: DocField<TDoc>, query?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
1307
|
+
max(field: DocField<TDoc>, query?: Record<string, unknown>, options?: Record<string, unknown>): Promise<number>;
|
|
1308
|
+
addSubdocument(parentId: string | ObjectId, arrayPath: DocField<TDoc>, subData: Record<string, unknown>, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1309
|
+
getSubdocument(parentId: string | ObjectId, arrayPath: DocField<TDoc>, subId: string | ObjectId, options?: {
|
|
1244
1310
|
lean?: boolean;
|
|
1245
1311
|
session?: unknown;
|
|
1246
1312
|
}): Promise<Record<string, unknown>>;
|
|
1247
|
-
updateSubdocument(parentId: string | ObjectId, arrayPath:
|
|
1313
|
+
updateSubdocument(parentId: string | ObjectId, arrayPath: DocField<TDoc>, subId: string | ObjectId, updateData: Record<string, unknown>, options?: {
|
|
1248
1314
|
session?: unknown;
|
|
1249
1315
|
}): Promise<TDoc>;
|
|
1250
|
-
deleteSubdocument(parentId: string | ObjectId, arrayPath:
|
|
1316
|
+
deleteSubdocument(parentId: string | ObjectId, arrayPath: DocField<TDoc>, subId: string | ObjectId, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1251
1317
|
restore(id: string | ObjectId, options?: {
|
|
1252
1318
|
session?: ClientSession;
|
|
1253
1319
|
}): Promise<TDoc>;
|
|
@@ -1294,4 +1360,4 @@ type AllPluginMethods<TDoc> = {
|
|
|
1294
1360
|
*/
|
|
1295
1361
|
type WithPlugins<TDoc, TRepo extends RepositoryInstance = RepositoryInstance> = TRepo & AllPluginMethods<TDoc>;
|
|
1296
1362
|
//#endregion
|
|
1297
|
-
export {
|
|
1363
|
+
export { ReadPreferenceType as $, InferDocument as A, LookupOptions as At, NonNullableFields as B, EventPayload as C, WithPlugins as Ct, GroupResult as D, IRequestContext as Dt, FieldRules as E, IControllerResponse as Et, KeysetPaginationResult as F, PaginationConfig as G, OffsetPaginationOptions as H, Logger as I, Plugin as J, PaginationResult as K, LookupPopulateOptions as L, JsonSchema as M, KeysOfType as N, HookMode as O, IResponseFormatter as Ot, KeysetPaginationOptions as P, ReadOptions as Q, LookupPopulateResult as R, EventHandlers as S, ValidatorDefinition as St, FieldPreset as T, IController as Tt, OffsetPaginationResult as U, ObjectId as V, OperationOptions as W, PluginType as X, PluginFunction as Y, PopulateSpec as Z, CrudSchemas as _, UpdateOptions as _t, AnyDocument as a, RequiredBy as at, DeleteResult as b, ValidationChainOptions as bt, CacheOperationOptions as c, SessionOptions as ct, CacheableOptions as d, SoftDeleteRepository as dt, RepositoryContext as et, CascadeOptions as f, SortDirection as ft, CreateOptions as g, UpdateManyResult as gt, CreateInput as h, UpdateInput as ht, AllPluginMethods as i, RepositoryOptions as it, InferRawDoc as j, HttpError as k, LookupBuilder as kt, CacheOptions as l, SoftDeleteFilterMode as lt, CollationOptions as m, Strict as mt, AggregatePaginationOptions as n, RepositoryInstance as nt, AnyModel as o, SchemaBuilderOptions as ot, CascadeRelation as p, SortSpec as pt, PartialBy as q, AggregatePaginationResult as r, RepositoryOperation as rt, CacheAdapter as s, SelectSpec as st, AggregateOptions as t, RepositoryEvent as tt, CacheStats as u, SoftDeleteOptions as ut, DecodedCursor as v, UpdateWithValidationResult as vt, EventPhase as w, WithTransactionOptions as wt, DocField as x, ValidationResult as xt, DeepPartial as y, UserContext as yt, MinMaxResult as z };
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as isFieldUpdateAllowed, c as configureLogger, d as getFieldsForUser, f as getMongooseProjection, i as getSystemManagedFields, l as createFieldPreset, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as createError, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as filterResponseData } from "../mongooseToJsonSchema-
|
|
1
|
+
import { Z as PopulateSpec, pt as SortSpec, st as SelectSpec } from "../types-nLhnjmdE.mjs";
|
|
2
|
+
import { a as isFieldUpdateAllowed, c as configureLogger, d as getFieldsForUser, f as getMongooseProjection, i as getSystemManagedFields, l as createFieldPreset, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as createError, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as filterResponseData } from "../mongooseToJsonSchema-MTvR0gJv.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/cache-keys.d.ts
|
|
5
5
|
/**
|
package/dist/{validation-chain.plugin-BNoaKDOm.d.mts → validation-chain.plugin-C-IGsWHn.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as
|
|
1
|
+
import { I as Logger, J as Plugin, St as ValidatorDefinition, T as FieldPreset, U as OffsetPaginationResult, V as ObjectId, Z as PopulateSpec, bt as ValidationChainOptions, et as RepositoryContext, f as CascadeOptions, l as CacheOptions, nt as RepositoryInstance, pt as SortSpec, st as SelectSpec, u as CacheStats, ut as SoftDeleteOptions } from "./types-nLhnjmdE.mjs";
|
|
2
2
|
import mongoose, { ClientSession } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/plugins/aggregate-helpers.plugin.d.ts
|
package/package.json
CHANGED