@classytic/mongokit 3.2.5 → 3.3.1
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/README.md +2 -2
- package/dist/actions/index.d.mts +2 -2
- package/dist/actions/index.mjs +1 -2
- package/dist/{aggregate-BAi4Do-X.mjs → aggregate-BClp040M.mjs} +80 -12
- package/dist/{aggregate-D9x87vej.d.mts → aggregate-BkOG9qwr.d.mts} +3 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/{cache-keys-C8Z9B5sw.mjs → cache-keys-CzFwVnLy.mjs} +28 -9
- package/dist/{custom-id.plugin-Dc4Y3Eie.d.mts → custom-id.plugin-BJ3FSnzt.d.mts} +51 -3
- package/dist/{custom-id.plugin-m0VW6yYm.mjs → custom-id.plugin-FInXDsUX.mjs} +1744 -76
- package/dist/index.d.mts +63 -15
- package/dist/index.mjs +10 -1146
- package/dist/{limits-DsNeCx4D.mjs → limits-s1-d8rWb.mjs} +2 -2
- package/dist/{mongooseToJsonSchema-1qQMScHL.d.mts → mongooseToJsonSchema-B6O2ED3n.d.mts} +1 -1
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +18 -5
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.mjs +1 -1
- package/dist/{types-Bnwv9NV6.d.mts → types-pVY0w1Pp.d.mts} +29 -3
- package/dist/utils/index.d.mts +22 -5
- package/dist/utils/index.mjs +2 -2
- package/package.json +3 -3
- package/dist/create-BuO6xt0v.mjs +0 -55
- /package/dist/{mongooseToJsonSchema-COdDEkIJ.mjs → mongooseToJsonSchema-D_i2Am_O.mjs} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as SchemaBuilderOptions, A as KeysetPaginationOptions, B as PaginationResult, C as GroupResult, D as InferRawDoc, E as InferDocument, F as ObjectId, G as PopulateSpec, H as Plugin, I as OffsetPaginationOptions, J as RepositoryEvent, K as ReadPreferenceType, L as OffsetPaginationResult, M as Logger, N as MinMaxResult, O as JsonSchema, P as NonNullableFields, Q as RequiredBy, R as OperationOptions, S as FieldRules, St as LookupOptions, T as HttpError, U as PluginFunction, V as PartialBy, W as PluginType, X as RepositoryOperation, Y as RepositoryInstance, Z as RepositoryOptions, _ as DeleteResult, _t as IController, a as AnyModel, at as SortSpec, b as EventPhase, bt as IResponseFormatter, c as CacheOptions, ct as UpdateManyResult, d as CascadeRelation, dt as UserContext, et as SelectSpec, f as CreateInput, ft as ValidationChainOptions, g as DeepPartial, gt as WithTransactionOptions, h as DecodedCursor, ht as WithPlugins, i as AnyDocument, it as SortDirection, j as KeysetPaginationResult, k as KeysOfType, l as CacheStats, lt as UpdateOptions, m as CrudSchemas, mt as ValidatorDefinition, n as AggregatePaginationResult, nt as SoftDeleteOptions, o as CacheAdapter, ot as Strict, p as CreateOptions, pt as ValidationResult, q as RepositoryContext, r as AllPluginMethods, rt as SoftDeleteRepository, s as CacheOperationOptions, st as UpdateInput, t as AggregatePaginationOptions, tt as SoftDeleteFilterMode, u as CascadeOptions, ut as UpdateWithValidationResult, v as EventHandlers, vt as IControllerResponse, w as HookMode, x as FieldPreset, xt as LookupBuilder, y as EventPayload, yt as IRequestContext, z as PaginationConfig } from "./types-
|
|
2
|
-
import "./aggregate-
|
|
1
|
+
import { $ as SchemaBuilderOptions, A as KeysetPaginationOptions, B as PaginationResult, C as GroupResult, D as InferRawDoc, E as InferDocument, F as ObjectId, G as PopulateSpec, H as Plugin, I as OffsetPaginationOptions, J as RepositoryEvent, K as ReadPreferenceType, L as OffsetPaginationResult, M as Logger, N as MinMaxResult, O as JsonSchema, P as NonNullableFields, Q as RequiredBy, R as OperationOptions, S as FieldRules, St as LookupOptions, T as HttpError, U as PluginFunction, V as PartialBy, W as PluginType, X as RepositoryOperation, Y as RepositoryInstance, Z as RepositoryOptions, _ as DeleteResult, _t as IController, a as AnyModel, at as SortSpec, b as EventPhase, bt as IResponseFormatter, c as CacheOptions, ct as UpdateManyResult, d as CascadeRelation, dt as UserContext, et as SelectSpec, f as CreateInput, ft as ValidationChainOptions, g as DeepPartial, gt as WithTransactionOptions, h as DecodedCursor, ht as WithPlugins, i as AnyDocument, it as SortDirection, j as KeysetPaginationResult, k as KeysOfType, l as CacheStats, lt as UpdateOptions, m as CrudSchemas, mt as ValidatorDefinition, n as AggregatePaginationResult, nt as SoftDeleteOptions, o as CacheAdapter, ot as Strict, p as CreateOptions, pt as ValidationResult, q as RepositoryContext, r as AllPluginMethods, rt as SoftDeleteRepository, s as CacheOperationOptions, st as UpdateInput, t as AggregatePaginationOptions, tt as SoftDeleteFilterMode, u as CascadeOptions, ut as UpdateWithValidationResult, v as EventHandlers, vt as IControllerResponse, w as HookMode, x as FieldPreset, xt as LookupBuilder, y as EventPayload, yt as IRequestContext, z as PaginationConfig } from "./types-pVY0w1Pp.mjs";
|
|
2
|
+
import "./aggregate-BkOG9qwr.mjs";
|
|
3
3
|
import { t as index_d_exports } from "./actions/index.mjs";
|
|
4
4
|
import { PaginationEngine } from "./pagination/PaginationEngine.mjs";
|
|
5
|
-
import { A as subdocumentPlugin, B as
|
|
6
|
-
import { a as isFieldUpdateAllowed, c as configureLogger, d as filterResponseData, f as getFieldsForUser, i as getSystemManagedFields, l as createError, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as getMongooseProjection, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as createFieldPreset } from "./mongooseToJsonSchema-
|
|
5
|
+
import { A as subdocumentPlugin, B as immutableField, C as observabilityPlugin, D as CacheMethods, E as cascadePlugin, F as batchOperationsPlugin, G as methodRegistryPlugin, H as uniqueField, I as MongoOperationsMethods, J as auditLogPlugin, K as SoftDeleteMethods, L as mongoOperationsPlugin, M as aggregateHelpersPlugin, N as BatchOperationsMethods, O as cachePlugin, P as BulkWriteResult, R as autoInject, S as OperationMetric, T as multiTenantPlugin, U as validationChainPlugin, V as requireField, X as fieldFilterPlugin, Y as timestampPlugin, _ as AuditTrailMethods, a as SequentialIdOptions, b as auditTrailPlugin, c as getNextSequence, d as ElasticSearchOptions, f as elasticSearchPlugin, g as AuditQueryResult, h as AuditQueryOptions, i as PrefixedIdOptions, j as AggregateHelpersMethods, k as SubdocumentMethods, l as prefixedId, m as AuditOperation, n as DateSequentialIdOptions, o as customIdPlugin, p as AuditEntry, q as softDeletePlugin, r as IdGenerator, s as dateSequentialId, t as CustomIdOptions, u as sequentialId, v as AuditTrailOptions, w as MultiTenantOptions, x as ObservabilityOptions, y as AuditTrailQuery, z as blockIf } from "./custom-id.plugin-BJ3FSnzt.mjs";
|
|
6
|
+
import { a as isFieldUpdateAllowed, c as configureLogger, d as filterResponseData, f as getFieldsForUser, i as getSystemManagedFields, l as createError, n as buildCrudSchemasFromMongooseSchema, o as validateUpdateBody, p as getMongooseProjection, r as getImmutableFields, s as createMemoryCache, t as buildCrudSchemasFromModel, u as createFieldPreset } from "./mongooseToJsonSchema-B6O2ED3n.mjs";
|
|
7
7
|
import * as mongoose$1 from "mongoose";
|
|
8
8
|
import { ClientSession, Expression, Model, PipelineStage, PopulateOptions } from "mongoose";
|
|
9
9
|
|
|
@@ -430,6 +430,22 @@ declare class AggregationBuilder {
|
|
|
430
430
|
//#endregion
|
|
431
431
|
//#region src/Repository.d.ts
|
|
432
432
|
type HookListener = (data: any) => void | Promise<void>;
|
|
433
|
+
/** Hook with priority for phase ordering */
|
|
434
|
+
interface PrioritizedHook {
|
|
435
|
+
listener: HookListener;
|
|
436
|
+
priority: number;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Plugin phase priorities (lower = runs first)
|
|
440
|
+
* Policy hooks (multi-tenant, soft-delete, validation) MUST run before cache
|
|
441
|
+
* to ensure filters are injected before cache keys are computed.
|
|
442
|
+
*/
|
|
443
|
+
declare const HOOK_PRIORITY: {
|
|
444
|
+
/** Policy enforcement: tenant isolation, soft-delete filtering, validation */readonly POLICY: 100; /** Caching: lookup/store after policy filters are applied */
|
|
445
|
+
readonly CACHE: 200; /** Observability: audit logging, metrics, telemetry */
|
|
446
|
+
readonly OBSERVABILITY: 300; /** Default priority for user-registered hooks */
|
|
447
|
+
readonly DEFAULT: 500;
|
|
448
|
+
};
|
|
433
449
|
/**
|
|
434
450
|
* Production-grade repository for MongoDB
|
|
435
451
|
* Event-driven, plugin-based, with smart pagination
|
|
@@ -437,7 +453,7 @@ type HookListener = (data: any) => void | Promise<void>;
|
|
|
437
453
|
declare class Repository<TDoc = any> {
|
|
438
454
|
readonly Model: Model<TDoc>;
|
|
439
455
|
readonly model: string;
|
|
440
|
-
readonly _hooks: Map<string,
|
|
456
|
+
readonly _hooks: Map<string, PrioritizedHook[]>;
|
|
441
457
|
readonly _pagination: PaginationEngine<TDoc>;
|
|
442
458
|
private readonly _hookMode;
|
|
443
459
|
[key: string]: unknown;
|
|
@@ -448,9 +464,17 @@ declare class Repository<TDoc = any> {
|
|
|
448
464
|
*/
|
|
449
465
|
use(plugin: PluginType): this;
|
|
450
466
|
/**
|
|
451
|
-
* Register event listener
|
|
452
|
-
|
|
453
|
-
|
|
467
|
+
* Register event listener with optional priority for phase ordering.
|
|
468
|
+
*
|
|
469
|
+
* @param event - Event name (e.g. 'before:getAll')
|
|
470
|
+
* @param listener - Hook function
|
|
471
|
+
* @param options - Optional { priority } — use HOOK_PRIORITY constants.
|
|
472
|
+
* Lower priority numbers run first.
|
|
473
|
+
* Default: HOOK_PRIORITY.DEFAULT (500)
|
|
474
|
+
*/
|
|
475
|
+
on(event: string, listener: HookListener, options?: {
|
|
476
|
+
priority?: number;
|
|
477
|
+
}): this;
|
|
454
478
|
/**
|
|
455
479
|
* Remove a specific event listener
|
|
456
480
|
*/
|
|
@@ -464,7 +488,7 @@ declare class Repository<TDoc = any> {
|
|
|
464
488
|
*/
|
|
465
489
|
emit(event: string, data: unknown): void;
|
|
466
490
|
/**
|
|
467
|
-
* Emit event and await all async handlers
|
|
491
|
+
* Emit event and await all async handlers (sorted by priority)
|
|
468
492
|
*/
|
|
469
493
|
emitAsync(event: string, data: unknown): Promise<void>;
|
|
470
494
|
private _emitHook;
|
|
@@ -563,12 +587,14 @@ declare class Repository<TDoc = any> {
|
|
|
563
587
|
}): Promise<OffsetPaginationResult<TDoc> | KeysetPaginationResult<TDoc>>;
|
|
564
588
|
/**
|
|
565
589
|
* Get or create document
|
|
590
|
+
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
566
591
|
*/
|
|
567
592
|
getOrCreate(query: Record<string, unknown>, createData: Record<string, unknown>, options?: {
|
|
568
593
|
session?: ClientSession;
|
|
569
594
|
}): Promise<TDoc | null>;
|
|
570
595
|
/**
|
|
571
596
|
* Count documents
|
|
597
|
+
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
572
598
|
*/
|
|
573
599
|
count(query?: Record<string, unknown>, options?: {
|
|
574
600
|
session?: ClientSession;
|
|
@@ -576,6 +602,7 @@ declare class Repository<TDoc = any> {
|
|
|
576
602
|
}): Promise<number>;
|
|
577
603
|
/**
|
|
578
604
|
* Check if document exists
|
|
605
|
+
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
579
606
|
*/
|
|
580
607
|
exists(query: Record<string, unknown>, options?: {
|
|
581
608
|
session?: ClientSession;
|
|
@@ -592,26 +619,41 @@ declare class Repository<TDoc = any> {
|
|
|
592
619
|
*/
|
|
593
620
|
delete(id: string | ObjectId, options?: {
|
|
594
621
|
session?: ClientSession;
|
|
595
|
-
}): Promise<
|
|
596
|
-
success: boolean;
|
|
597
|
-
message: string;
|
|
598
|
-
}>;
|
|
622
|
+
}): Promise<DeleteResult>;
|
|
599
623
|
/**
|
|
600
624
|
* Execute aggregation pipeline
|
|
625
|
+
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
626
|
+
*
|
|
627
|
+
* @param pipeline - Aggregation pipeline stages
|
|
628
|
+
* @param options - Aggregation options including governance controls
|
|
601
629
|
*/
|
|
602
630
|
aggregate<TResult = unknown>(pipeline: PipelineStage[], options?: {
|
|
603
631
|
session?: ClientSession;
|
|
632
|
+
allowDiskUse?: boolean;
|
|
633
|
+
comment?: string;
|
|
634
|
+
readPreference?: ReadPreferenceType;
|
|
635
|
+
maxTimeMS?: number;
|
|
636
|
+
readConcern?: {
|
|
637
|
+
level: string;
|
|
638
|
+
};
|
|
639
|
+
collation?: Record<string, unknown>;
|
|
640
|
+
maxPipelineStages?: number;
|
|
604
641
|
}): Promise<TResult[]>;
|
|
605
642
|
/**
|
|
606
643
|
* Aggregate pipeline with pagination
|
|
607
644
|
* Best for: Complex queries, grouping, joins
|
|
645
|
+
*
|
|
646
|
+
* Policy hooks (multi-tenant, soft-delete) inject context.filters which are
|
|
647
|
+
* prepended as a $match stage to the pipeline, ensuring tenant isolation.
|
|
608
648
|
*/
|
|
609
649
|
aggregatePaginate(options?: AggregatePaginationOptions): Promise<AggregatePaginationResult<TDoc>>;
|
|
610
650
|
/**
|
|
611
651
|
* Get distinct values
|
|
652
|
+
* Routes through hook system for policy enforcement (multi-tenant, soft-delete)
|
|
612
653
|
*/
|
|
613
654
|
distinct<T = unknown>(field: string, query?: Record<string, unknown>, options?: {
|
|
614
655
|
session?: ClientSession;
|
|
656
|
+
readPreference?: ReadPreferenceType;
|
|
615
657
|
}): Promise<T[]>;
|
|
616
658
|
/**
|
|
617
659
|
* Query with custom field lookups ($lookup)
|
|
@@ -726,7 +768,13 @@ declare class Repository<TDoc = any> {
|
|
|
726
768
|
*/
|
|
727
769
|
_executeQuery<T>(buildQuery: (Model: Model<TDoc>) => Promise<T>): Promise<T>;
|
|
728
770
|
/**
|
|
729
|
-
* Build operation context and run before hooks
|
|
771
|
+
* Build operation context and run before hooks (sorted by priority).
|
|
772
|
+
*
|
|
773
|
+
* Hook execution order is deterministic:
|
|
774
|
+
* 1. POLICY (100) — tenant isolation, soft-delete filtering, validation
|
|
775
|
+
* 2. CACHE (200) — cache lookup (after policy filters are injected)
|
|
776
|
+
* 3. OBSERVABILITY (300) — audit logging, metrics
|
|
777
|
+
* 4. DEFAULT (500) — user-registered hooks
|
|
730
778
|
*/
|
|
731
779
|
_buildContext(operation: string, options: Record<string, unknown>): Promise<RepositoryContext>;
|
|
732
780
|
/**
|
|
@@ -1046,4 +1094,4 @@ declare class QueryParser {
|
|
|
1046
1094
|
*/
|
|
1047
1095
|
declare function createRepository<TDoc>(Model: mongoose$1.Model<TDoc, any, any, any>, plugins?: PluginType[], paginationConfig?: PaginationConfig, options?: RepositoryOptions): Repository<TDoc>;
|
|
1048
1096
|
//#endregion
|
|
1049
|
-
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 CacheAdapter, type CacheMethods, type CacheOperationOptions, type CacheOptions, type CacheStats, type CascadeOptions, type CascadeRelation, 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, 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, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validateUpdateBody, validationChainPlugin };
|
|
1097
|
+
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 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, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validateUpdateBody, validationChainPlugin };
|