@classytic/mongokit 3.10.3 → 3.11.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 +10 -0
- package/dist/{PaginationEngine-B93fLCcO.mjs → PaginationEngine-CvDFfVXT.mjs} +1 -1
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/{error-CzYwrfUP.mjs → error-B00pI7dV.mjs} +11 -4
- package/dist/{index-CNNavGpM.d.mts → index-dNTmpgK8.d.mts} +1 -1
- package/dist/index.d.mts +60 -6
- package/dist/index.mjs +19 -4
- package/dist/{mongooseToJsonSchema-Bi8hNbj8.d.mts → mongooseToJsonSchema-DXxjFkLB.d.mts} +36 -7
- package/dist/pagination/PaginationEngine.d.mts +1 -1
- package/dist/pagination/PaginationEngine.mjs +1 -1
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/{types-CYFJa36g.d.mts → types-Dc2aDVUi.d.mts} +34 -17
- package/dist/{update-CWXfFC6O.mjs → update-DEJYcgfV.mjs} +1 -1
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/{validation-chain.plugin-BYJo0Y6g.d.mts → validation-chain.plugin-B0VSdcwa.d.mts} +6 -38
- package/dist/{validation-chain.plugin-D-yH2f8a.mjs → validation-chain.plugin-Dllv-cml.mjs} +172 -307
- package/package.json +143 -143
package/README.md
CHANGED
|
@@ -269,6 +269,16 @@ const result = await invoiceRepo.getAll({ filters, sort, page, limit, search });
|
|
|
269
269
|
|
|
270
270
|
Supports URL operators: `_gt/_gte/_lt/_lte/_ne/_in/_nin/_regex`, geo (`[near]`, `[withinRadius]`, `[geoWithin]`), populate, and schema-aware coercion. ReDoS protection + allowlisted operators for hardening.
|
|
271
271
|
|
|
272
|
+
**Nested subdocument filters.** Dotted paths pass through to MongoDB directly — Mongoose's strict-mode casting handles the nested-schema lookup, no special config required:
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
?contact.email[contains]=foo → { 'contact.email': { $regex: /foo/i } }
|
|
276
|
+
?name.given=sadman → { 'name.given': 'sadman' }
|
|
277
|
+
?name.given[in]=a,b → { 'name.given': { $in: ['a', 'b'] } }
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Dot-in-key semantics follow `qs` parsing: `?name.given=x` produces `{ 'name.given': 'x' }` (NOT nested into `{ name: { given: 'x' } }`). For the nested-object form use bracket notation: `?name[given]=x`.
|
|
281
|
+
|
|
272
282
|
---
|
|
273
283
|
|
|
274
284
|
## TypeScript
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as warn } from "./logger-DJ7egMnd.mjs";
|
|
2
|
-
import { t as createError } from "./error-
|
|
2
|
+
import { t as createError } from "./error-B00pI7dV.mjs";
|
|
3
3
|
import { n as encodeCursor, r as resolveCursorFilter } from "./cursor-J84rR6wG.mjs";
|
|
4
4
|
import { r as validateKeysetSort, t as getPrimaryField } from "./sort-CrZjTK25.mjs";
|
|
5
5
|
//#region src/pagination/utils/index-hint.ts
|
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-dNTmpgK8.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/actions/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "../chunk-CfYAbeIz.mjs";
|
|
2
|
-
import { g as create_exports, i as update_exports, p as delete_exports, u as read_exports, v as aggregate_exports } from "../update-
|
|
2
|
+
import { g as create_exports, i as update_exports, p as delete_exports, u as read_exports, v as aggregate_exports } from "../update-DEJYcgfV.mjs";
|
|
3
3
|
//#region src/actions/index.ts
|
|
4
4
|
var actions_exports = /* @__PURE__ */ __exportAll({
|
|
5
5
|
aggregate: () => aggregate_exports,
|
package/dist/ai/index.d.mts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
//#region src/utils/error.ts
|
|
2
2
|
/**
|
|
3
|
-
* Creates an error with HTTP status code
|
|
3
|
+
* Creates an error with HTTP status code, plus optional stable `code` /
|
|
4
|
+
* `meta` so callers can `catch` on the code instead of regex-matching the
|
|
5
|
+
* message string.
|
|
4
6
|
*
|
|
5
7
|
* @param status - HTTP status code
|
|
6
8
|
* @param message - Error message
|
|
9
|
+
* @param options - Optional `code` / `meta` for structured handling
|
|
7
10
|
* @returns Error with status property
|
|
8
11
|
*
|
|
9
12
|
* @example
|
|
10
13
|
* throw createError(404, 'Document not found');
|
|
11
|
-
* throw createError(400, 'Invalid input'
|
|
12
|
-
*
|
|
14
|
+
* throw createError(400, 'Invalid input', {
|
|
15
|
+
* code: 'SEARCH_NOT_CONFIGURED',
|
|
16
|
+
* meta: { model: 'Customer', availableModes: ['text', 'regex', 'auto'] },
|
|
17
|
+
* });
|
|
13
18
|
*/
|
|
14
|
-
function createError(status, message) {
|
|
19
|
+
function createError(status, message, options) {
|
|
15
20
|
const error = new Error(message);
|
|
16
21
|
error.status = status;
|
|
22
|
+
if (options?.code !== void 0) error.code = options.code;
|
|
23
|
+
if (options?.meta !== void 0) error.meta = options.meta;
|
|
17
24
|
return error;
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as ReadPreferenceType, B as ObjectId, D as GroupResult, E as FindOneAndUpdateOptions, R as MinMaxResult, U as OperationOptions, X as PopulateSpec, a as AnyDocument, b as DeleteResult, ft as SortSpec, g as CreateOptions, gt as UpdateOptions, ht as UpdateManyResult, kt as LookupOptions, ot as SelectSpec, vt as UpdateWithValidationResult } from "./types-Dc2aDVUi.mjs";
|
|
2
2
|
import { Model, PipelineStage } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/actions/aggregate.d.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { t as index_d_exports } from "./index-
|
|
1
|
+
import { $ as ReadPreferenceType, A as InferDocument, B as ObjectId, C as EventPayload, Ct as WithTransactionOptions, D as GroupResult, Dt as IResponseFormatter, E as FindOneAndUpdateOptions, Et as IRequestContext, F as Logger, G as PaginationResult, H as OffsetPaginationResult, I as LookupPopulateOptions, J as PluginFunction, K as PartialBy, L as LookupPopulateResult, M as KeysOfType, N as KeysetPaginationOptions, O as HookMode, Ot as LookupBuilder, P as KeysetPaginationResult, Q as ReadOptions, R as MinMaxResult, S as EventHandlers, St as WithPlugins, T as FieldPreset, Tt as IControllerResponse, U as OperationOptions, V as OffsetPaginationOptions, W as PaginationConfig, X as PopulateSpec, Y as PluginType, Z as PrioritizedHook, _ as DecodedCursor, _t as UpdatePatch, a as AnyDocument, at as RequiredBy, b as DeleteResult, bt as ValidationChainOptions, c as CacheOperationOptions, ct as SoftDeleteFilterMode, d as CacheableOptions, dt as SortDirection, et as RepositoryContext, f as CascadeOptions, ft as SortSpec, g as CreateOptions, gt as UpdateOptions, h as CreateInput, ht as UpdateManyResult, i as AllPluginMethods, it as RepositoryOptions, j as InferRawDoc, k as HttpError, kt as LookupOptions, l as CacheOptions, lt as SoftDeleteOptions, m as CollationOptions, mt as UpdateInput, n as AggregatePaginationOptions, nt as RepositoryInstance, o as AnyModel, ot as SelectSpec, p as CascadeRelation, pt as Strict, q as Plugin, r as AggregatePaginationResult, rt as RepositoryOperation, s as CacheAdapter, st as SessionOptions, t as AggregateOptions, tt as RepositoryEvent, u as CacheStats, ut as SoftDeleteRepository, v as DeepPartial, vt as UpdateWithValidationResult, w as EventPhase, wt as IController, x as DocField, xt as ValidatorDefinition, y as DeleteManyResult, yt as UserContext, z as NonNullableFields } from "./types-Dc2aDVUi.mjs";
|
|
2
|
+
import { t as index_d_exports } from "./index-dNTmpgK8.mjs";
|
|
3
3
|
import { PaginationEngine } from "./pagination/PaginationEngine.mjs";
|
|
4
|
-
import { $ as aggregateHelpersPlugin, A as PrefixedIdOptions, B as BatchOperationsMethods, C as methodRegistryPlugin, D as CustomIdOptions, E as elasticSearchPlugin, F as prefixedId, G as AuditQueryOptions, H as batchOperationsPlugin, I as sequentialId, J as AuditTrailOptions, K as AuditQueryResult, L as cascadePlugin, M as customIdPlugin, N as dateSequentialId, O as DateSequentialIdOptions, P as getNextSequence, Q as AggregateHelpersMethods, R as CacheMethods, T as ElasticSearchOptions, U as AuditEntry, V as BulkWriteResult, W as AuditOperation, X as auditTrailPlugin, Y as AuditTrailQuery, Z as auditLogPlugin, _ as observabilityPlugin, a as uniqueField, b as MongoOperationsMethods, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as SequentialIdOptions, k as IdGenerator, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, q as AuditTrailMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MultiTenantOptions, w as fieldFilterPlugin, x as mongoOperationsPlugin, y as multiTenantPlugin, z as cachePlugin } from "./validation-chain.plugin-
|
|
4
|
+
import { $ as aggregateHelpersPlugin, A as PrefixedIdOptions, B as BatchOperationsMethods, C as methodRegistryPlugin, D as CustomIdOptions, E as elasticSearchPlugin, F as prefixedId, G as AuditQueryOptions, H as batchOperationsPlugin, I as sequentialId, J as AuditTrailOptions, K as AuditQueryResult, L as cascadePlugin, M as customIdPlugin, N as dateSequentialId, O as DateSequentialIdOptions, P as getNextSequence, Q as AggregateHelpersMethods, R as CacheMethods, T as ElasticSearchOptions, U as AuditEntry, V as BulkWriteResult, W as AuditOperation, X as auditTrailPlugin, Y as AuditTrailQuery, Z as auditLogPlugin, _ as observabilityPlugin, a as uniqueField, b as MongoOperationsMethods, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as SequentialIdOptions, k as IdGenerator, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, q as AuditTrailMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MultiTenantOptions, w as fieldFilterPlugin, x as mongoOperationsPlugin, y as multiTenantPlugin, z as cachePlugin } from "./validation-chain.plugin-B0VSdcwa.mjs";
|
|
5
5
|
import { n as SchemaPathsLike, t as FieldType$1 } from "./coercion-oM8G4b6m.mjs";
|
|
6
6
|
import { n as SchemaIndexes } from "./indexes-C26GNZRU.mjs";
|
|
7
|
-
import { a as createFieldPreset, c as getMongooseProjection, d as parseDuplicateKeyError, i as configureLogger, l as createError, n as buildCrudSchemasFromMongooseSchema, o as filterResponseData, r as createMemoryCache, s as getFieldsForUser, t as buildCrudSchemasFromModel, u as isDuplicateKeyError } from "./mongooseToJsonSchema-
|
|
7
|
+
import { a as createFieldPreset, c as getMongooseProjection, d as parseDuplicateKeyError, i as configureLogger, l as createError, n as buildCrudSchemasFromMongooseSchema, o as filterResponseData, r as createMemoryCache, s as getFieldsForUser, t as buildCrudSchemasFromModel, u as isDuplicateKeyError } from "./mongooseToJsonSchema-DXxjFkLB.mjs";
|
|
8
8
|
import * as _$mongoose from "mongoose";
|
|
9
9
|
import { ClientSession, Expression, Model, PipelineStage, PopulateOptions } from "mongoose";
|
|
10
10
|
import { AggPaginationRequest, AggRequest, AggResult, RepositoryBase } from "@classytic/repo-core/repository";
|
|
11
|
+
import { UpdateInput as UpdateInput$1 } from "@classytic/repo-core/update";
|
|
11
12
|
import { OffsetPaginationResultCore } from "@classytic/repo-core/pagination";
|
|
12
13
|
|
|
13
14
|
//#region src/operations.d.ts
|
|
@@ -929,6 +930,17 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
|
|
|
929
930
|
*/
|
|
930
931
|
private _emitHook;
|
|
931
932
|
private _emitErrorHook;
|
|
933
|
+
/**
|
|
934
|
+
* Run a Repository operation under the standard envelope:
|
|
935
|
+
* - invoke `fn`, emit `after:<op>` with `{ context, result }` on success
|
|
936
|
+
* - emit `error:<op>` and rethrow via `_handleError` on failure
|
|
937
|
+
*
|
|
938
|
+
* Methods with branched in-try logic that emit `after:*` from multiple
|
|
939
|
+
* paths (`getById`, `update`, `delete`, `deleteMany`, `aggregatePaginate`,
|
|
940
|
+
* `lookupPopulate`) intentionally keep their inline try/catch rather than
|
|
941
|
+
* being restructured to return a single result through this helper.
|
|
942
|
+
*/
|
|
943
|
+
private _runOp;
|
|
932
944
|
/**
|
|
933
945
|
* Create single document
|
|
934
946
|
*/
|
|
@@ -1060,7 +1072,7 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
|
|
|
1060
1072
|
* );
|
|
1061
1073
|
* ```
|
|
1062
1074
|
*/
|
|
1063
|
-
findOneAndUpdate<TResult = TDoc>(filter: Record<string, unknown>, update:
|
|
1075
|
+
findOneAndUpdate<TResult = TDoc>(filter: Record<string, unknown>, update: UpdateInput$1, options?: FindOneAndUpdateOptions): Promise<TResult | null>;
|
|
1064
1076
|
/**
|
|
1065
1077
|
* Delete a document by ID.
|
|
1066
1078
|
*
|
|
@@ -1087,6 +1099,48 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
|
|
|
1087
1099
|
mode?: 'hard' | 'soft'; /** Legacy opt-in: throw a 404 error on miss instead of returning `{ success: false }`. */
|
|
1088
1100
|
throwOnNotFound?: boolean;
|
|
1089
1101
|
}): Promise<DeleteResult>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Update every document matching the filter.
|
|
1104
|
+
*
|
|
1105
|
+
* Promoted from `batchOperationsPlugin` to a class primitive in 3.11.0 so
|
|
1106
|
+
* the surface matches sqlitekit's always-available `updateMany`. Consumers
|
|
1107
|
+
* who forget to wire `batchOperationsPlugin` no longer get a runtime
|
|
1108
|
+
* `TypeError: repo.updateMany is not a function` — the method is always
|
|
1109
|
+
* here.
|
|
1110
|
+
*
|
|
1111
|
+
* Accepts three `update` forms via `UpdateInput`:
|
|
1112
|
+
* - Portable `UpdateSpec` from `@classytic/repo-core/update` (compiled to
|
|
1113
|
+
* `$set`/`$unset`/`$inc`/`$setOnInsert` before hooks run).
|
|
1114
|
+
* - Raw Mongo operator record (`{ $set, $inc, ... }`) — passed through.
|
|
1115
|
+
* - Mongo aggregation pipeline (`[...]`) — requires `updatePipeline: true`
|
|
1116
|
+
* to guard against accidental pipeline updates.
|
|
1117
|
+
*
|
|
1118
|
+
* Refuses empty filters (defense-in-depth against mass-update accidents)
|
|
1119
|
+
* both before and after policy hooks inject tenant scope.
|
|
1120
|
+
*/
|
|
1121
|
+
updateMany(filter: Record<string, unknown>, update: UpdateInput$1, options?: SessionOptions & {
|
|
1122
|
+
updatePipeline?: boolean;
|
|
1123
|
+
[key: string]: unknown;
|
|
1124
|
+
}): Promise<UpdateManyResult>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Delete every document matching the filter.
|
|
1127
|
+
*
|
|
1128
|
+
* Promoted from `batchOperationsPlugin` to a class primitive in 3.11.0 for
|
|
1129
|
+
* the same reason as `updateMany` — sqlitekit parity and no silent "method
|
|
1130
|
+
* is undefined" footgun when the batch plugin isn't wired.
|
|
1131
|
+
*
|
|
1132
|
+
* Behavior mirrors `delete()`: defaults to soft delete when
|
|
1133
|
+
* `softDeletePlugin` is wired, physical delete otherwise. Pass
|
|
1134
|
+
* `{ mode: 'hard' }` to bypass soft-delete — multi-tenant scoping, audit,
|
|
1135
|
+
* and cache hooks still fire.
|
|
1136
|
+
*
|
|
1137
|
+
* Rejects empty filters up front AND after policy hooks, so a policy-plugin
|
|
1138
|
+
* bug that zeroes out the query can't be exploited to wipe a collection.
|
|
1139
|
+
*/
|
|
1140
|
+
deleteMany(filter: Record<string, unknown>, options?: SessionOptions & {
|
|
1141
|
+
mode?: 'hard' | 'soft';
|
|
1142
|
+
[key: string]: unknown;
|
|
1143
|
+
}): Promise<DeleteManyResult>;
|
|
1090
1144
|
/**
|
|
1091
1145
|
* Kit-native aggregation pipeline — takes a MongoDB stage array and
|
|
1092
1146
|
* returns the raw pipeline output. Use this for `$lookup`, `$unwind`,
|
|
@@ -1418,4 +1472,4 @@ declare function isTransactionUnsupported(error: Error): boolean;
|
|
|
1418
1472
|
*/
|
|
1419
1473
|
declare function createRepository<TDoc>(Model: _$mongoose.Model<TDoc, any, any, any>, plugins?: PluginType[], paginationConfig?: PaginationConfig, options?: RepositoryOptions): Repository<TDoc>;
|
|
1420
1474
|
//#endregion
|
|
1421
|
-
export { ALL_OPERATIONS, 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 CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DeleteResult, type DocField, type ElasticSearchOptions, type EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, HOOK_PRIORITY, type HookMode, type HttpError, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type KeysetPaginationResult, type Logger, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MUTATING_OPERATIONS, type MinMaxResult, type MongoOperationsMethods, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OffsetPaginationResult, type OperationDescriptor, type OperationMetric, type OperationOptions, type PaginationConfig, PaginationEngine, type PaginationResult, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, QueryParser, type QueryParserOptions, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, Repository, Repository as default, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RequiredBy, type SchemaLike, 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 TenantContext, type TenantStore, type UpdateInput, type UpdateManyResult, type UpdateOptions, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, 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, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, immutableField, isDuplicateKeyError, isTransactionUnsupported, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
|
|
1475
|
+
export { ALL_OPERATIONS, 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 CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DeleteResult, type DocField, type ElasticSearchOptions, type EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, HOOK_PRIORITY, type HookMode, type HttpError, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type KeysetPaginationResult, type Logger, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MUTATING_OPERATIONS, type MinMaxResult, type MongoOperationsMethods, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OffsetPaginationResult, type OperationDescriptor, type OperationMetric, type OperationOptions, type PaginationConfig, PaginationEngine, type PaginationResult, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, QueryParser, type QueryParserOptions, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, Repository, Repository as default, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RequiredBy, type SchemaLike, 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 TenantContext, type TenantStore, type UpdateInput, type UpdateManyResult, type UpdateOptions, type UpdatePatch, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, 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, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, immutableField, isDuplicateKeyError, isTransactionUnsupported, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as warn, t as configureLogger } from "./logger-DJ7egMnd.mjs";
|
|
2
|
-
import { b as LookupBuilder } from "./update-
|
|
3
|
-
import { n as isDuplicateKeyError, r as parseDuplicateKeyError, t as createError } from "./error-
|
|
2
|
+
import { b as LookupBuilder } from "./update-DEJYcgfV.mjs";
|
|
3
|
+
import { n as isDuplicateKeyError, r as parseDuplicateKeyError, t as createError } from "./error-B00pI7dV.mjs";
|
|
4
4
|
import { t as actions_exports } from "./actions/index.mjs";
|
|
5
|
-
import { A as AuditTrailQuery, C as cachePlugin, D as withTransaction, E as isTransactionUnsupported, F as MUTATING_OPERATIONS, I as OP_REGISTRY, L as READ_OPERATIONS, M as auditLogPlugin, N as aggregateHelpersPlugin, O as AggregationBuilder, P as ALL_OPERATIONS, R as operationsByPolicyKey, S as cascadePlugin, T as Repository, _ as customIdPlugin, a as uniqueField, b as prefixedId, c as createTenantContext, d as observabilityPlugin, f as multiTenantPlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, j as auditTrailPlugin, k as batchOperationsPlugin, l as subdocumentPlugin, m as methodRegistryPlugin, n as blockIf, o as validationChainPlugin, p as mongoOperationsPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as dateSequentialId, w as HOOK_PRIORITY, x as sequentialId, y as getNextSequence } from "./validation-chain.plugin-
|
|
6
|
-
import { t as PaginationEngine } from "./PaginationEngine-
|
|
5
|
+
import { A as AuditTrailQuery, C as cachePlugin, D as withTransaction, E as isTransactionUnsupported, F as MUTATING_OPERATIONS, I as OP_REGISTRY, L as READ_OPERATIONS, M as auditLogPlugin, N as aggregateHelpersPlugin, O as AggregationBuilder, P as ALL_OPERATIONS, R as operationsByPolicyKey, S as cascadePlugin, T as Repository, _ as customIdPlugin, a as uniqueField, b as prefixedId, c as createTenantContext, d as observabilityPlugin, f as multiTenantPlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, j as auditTrailPlugin, k as batchOperationsPlugin, l as subdocumentPlugin, m as methodRegistryPlugin, n as blockIf, o as validationChainPlugin, p as mongoOperationsPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as dateSequentialId, w as HOOK_PRIORITY, x as sequentialId, y as getNextSequence } from "./validation-chain.plugin-Dllv-cml.mjs";
|
|
6
|
+
import { t as PaginationEngine } from "./PaginationEngine-CvDFfVXT.mjs";
|
|
7
7
|
import { isGeoOperator, parseGeoFilter } from "./query/primitives/geo.mjs";
|
|
8
8
|
import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-dI0m4RBs.mjs";
|
|
9
9
|
import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
|
|
@@ -11,6 +11,20 @@ import { extractSchemaIndexes } from "./query/primitives/indexes.mjs";
|
|
|
11
11
|
import { n as buildCrudSchemasFromMongooseSchema, r as createMemoryCache, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-D1sdCOmj.mjs";
|
|
12
12
|
//#region src/query/QueryParser.ts
|
|
13
13
|
/**
|
|
14
|
+
* Top-level query parameters that mongokit handles outside the filter
|
|
15
|
+
* pipeline. Used by `_handleBracketSyntax` to detect a common typo where a
|
|
16
|
+
* caller wrote `?filters[limit]=5` instead of `?limit=5` and the qs parser
|
|
17
|
+
* nested the key under a filter object — the value is silently dropped
|
|
18
|
+
* without this guard. Kept as a Set for O(1) lookup; values mirror the
|
|
19
|
+
* reserved-key list at the top of `_parseFilters`.
|
|
20
|
+
*/
|
|
21
|
+
const RESERVED_PAGINATION_KEYS = new Set([
|
|
22
|
+
"page",
|
|
23
|
+
"limit",
|
|
24
|
+
"sort",
|
|
25
|
+
"select"
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
14
28
|
* Modern Query Parser
|
|
15
29
|
* Converts URL parameters to MongoDB queries with $lookup support
|
|
16
30
|
*/
|
|
@@ -711,6 +725,7 @@ var QueryParser = class {
|
|
|
711
725
|
warn(`[mongokit] Nested filter depth exceeds maximum, skipping field: ${field}`);
|
|
712
726
|
return;
|
|
713
727
|
}
|
|
728
|
+
for (const op of Object.keys(operators)) if (RESERVED_PAGINATION_KEYS.has(op)) warn(`[mongokit] Nested filter contains reserved key '${op}' at '${field}.${op}' — did you mean ?${op}=... at the top level? The nested value is ignored.`);
|
|
714
729
|
if (!parsedFilters[field]) parsedFilters[field] = {};
|
|
715
730
|
for (const [operator, value] of Object.entries(operators)) {
|
|
716
731
|
if (value === "" || value === null || value === void 0) continue;
|
|
@@ -1,21 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { T as FieldPreset, k as HttpError, s as CacheAdapter, yt as UserContext } from "./types-Dc2aDVUi.mjs";
|
|
2
2
|
import mongoose, { Schema } from "mongoose";
|
|
3
3
|
import { CrudSchemas, SchemaBuilderOptions } from "@classytic/repo-core/schema";
|
|
4
4
|
|
|
5
5
|
//#region src/utils/error.d.ts
|
|
6
|
+
/** Optional structured fields for createError. */
|
|
7
|
+
interface CreateErrorOptions {
|
|
8
|
+
/** Stable machine-readable code (e.g. `SEARCH_NOT_CONFIGURED`). */
|
|
9
|
+
code?: string;
|
|
10
|
+
/** Diagnostic context — model name, configured modes, doc URL, etc. */
|
|
11
|
+
meta?: Record<string, unknown>;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
|
-
* Creates an error with HTTP status code
|
|
14
|
+
* Creates an error with HTTP status code, plus optional stable `code` /
|
|
15
|
+
* `meta` so callers can `catch` on the code instead of regex-matching the
|
|
16
|
+
* message string.
|
|
8
17
|
*
|
|
9
18
|
* @param status - HTTP status code
|
|
10
19
|
* @param message - Error message
|
|
20
|
+
* @param options - Optional `code` / `meta` for structured handling
|
|
11
21
|
* @returns Error with status property
|
|
12
22
|
*
|
|
13
23
|
* @example
|
|
14
24
|
* throw createError(404, 'Document not found');
|
|
15
|
-
* throw createError(400, 'Invalid input'
|
|
16
|
-
*
|
|
25
|
+
* throw createError(400, 'Invalid input', {
|
|
26
|
+
* code: 'SEARCH_NOT_CONFIGURED',
|
|
27
|
+
* meta: { model: 'Customer', availableModes: ['text', 'regex', 'auto'] },
|
|
28
|
+
* });
|
|
17
29
|
*/
|
|
18
|
-
declare function createError(status: number, message: string): HttpError;
|
|
30
|
+
declare function createError(status: number, message: string, options?: CreateErrorOptions): HttpError;
|
|
19
31
|
/**
|
|
20
32
|
* Boolean classifier: true when `err` is an authoritative MongoDB duplicate
|
|
21
33
|
* key error — and ONLY then. Used by arc's outbox / idempotency adapters to
|
|
@@ -171,13 +183,30 @@ declare function configureLogger(config: Partial<LoggerConfig> | false): void;
|
|
|
171
183
|
declare function createMemoryCache(maxEntries?: number): CacheAdapter;
|
|
172
184
|
//#endregion
|
|
173
185
|
//#region src/utils/mongooseToJsonSchema.d.ts
|
|
186
|
+
/**
|
|
187
|
+
* Return shape for the schema builders. Structurally a `CrudSchemas` plus
|
|
188
|
+
* an `[key: string]: unknown` index signature so the function reference
|
|
189
|
+
* plugs directly into HTTP-framework adapter callbacks typed as
|
|
190
|
+
* `OpenApiSchemas | Record<string, unknown>` (e.g. arc's
|
|
191
|
+
* `MongooseAdapterOptions.schemaGenerator`).
|
|
192
|
+
*
|
|
193
|
+
* `CrudSchemas` itself is intentionally a closed 4-field shape in
|
|
194
|
+
* `@classytic/repo-core/schema` — widening at the kit boundary keeps that
|
|
195
|
+
* contract intact while removing the `as unknown as Record<string, unknown>`
|
|
196
|
+
* cast every arc + mongokit host previously needed at the wiring site.
|
|
197
|
+
*
|
|
198
|
+
* The intersection has zero runtime cost: every `CrudSchemas` value
|
|
199
|
+
* already satisfies `Record<string, unknown>` structurally; TypeScript
|
|
200
|
+
* just refuses the assignment without an explicit declaration.
|
|
201
|
+
*/
|
|
202
|
+
type CrudSchemasFramework = CrudSchemas & Record<string, unknown>;
|
|
174
203
|
/**
|
|
175
204
|
* Build CRUD schemas from Mongoose schema
|
|
176
205
|
*/
|
|
177
|
-
declare function buildCrudSchemasFromMongooseSchema(mongooseSchema: Schema, options?: SchemaBuilderOptions):
|
|
206
|
+
declare function buildCrudSchemasFromMongooseSchema(mongooseSchema: Schema, options?: SchemaBuilderOptions): CrudSchemasFramework;
|
|
178
207
|
/**
|
|
179
208
|
* Build CRUD schemas from Mongoose model
|
|
180
209
|
*/
|
|
181
|
-
declare function buildCrudSchemasFromModel(mongooseModel: mongoose.Model<unknown>, options?: SchemaBuilderOptions):
|
|
210
|
+
declare function buildCrudSchemasFromModel(mongooseModel: mongoose.Model<unknown>, options?: SchemaBuilderOptions): CrudSchemasFramework;
|
|
182
211
|
//#endregion
|
|
183
212
|
export { createFieldPreset as a, getMongooseProjection as c, parseDuplicateKeyError as d, configureLogger as i, createError as l, buildCrudSchemasFromMongooseSchema as n, filterResponseData as o, createMemoryCache as r, getFieldsForUser as s, buildCrudSchemasFromModel as t, isDuplicateKeyError as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as OffsetPaginationResult, N as KeysetPaginationOptions, P as KeysetPaginationResult, V as OffsetPaginationOptions, W as PaginationConfig, a as AnyDocument, n as AggregatePaginationOptions, r as AggregatePaginationResult } from "../types-Dc2aDVUi.mjs";
|
|
2
2
|
import { Model } from "mongoose";
|
|
3
3
|
|
|
4
4
|
//#region src/pagination/PaginationEngine.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PaginationEngine } from "../PaginationEngine-
|
|
1
|
+
import { t as PaginationEngine } from "../PaginationEngine-CvDFfVXT.mjs";
|
|
2
2
|
export { PaginationEngine };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as aggregateHelpersPlugin, A as PrefixedIdOptions, B as BatchOperationsMethods, C as methodRegistryPlugin, D as CustomIdOptions, E as elasticSearchPlugin, F as prefixedId, G as AuditQueryOptions, H as batchOperationsPlugin, I as sequentialId, J as AuditTrailOptions, K as AuditQueryResult, L as cascadePlugin, M as customIdPlugin, N as dateSequentialId, O as DateSequentialIdOptions, P as getNextSequence, Q as AggregateHelpersMethods, R as CacheMethods, S as MethodRegistryRepository, T as ElasticSearchOptions, U as AuditEntry, W as AuditOperation, X as auditTrailPlugin, Y as AuditTrailQuery, Z as auditLogPlugin, _ as observabilityPlugin, a as uniqueField, b as MongoOperationsMethods, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as SequentialIdOptions, k as IdGenerator, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, q as AuditTrailMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MultiTenantOptions, w as fieldFilterPlugin, x as mongoOperationsPlugin, y as multiTenantPlugin, z as cachePlugin } from "../validation-chain.plugin-
|
|
1
|
+
import { $ as aggregateHelpersPlugin, A as PrefixedIdOptions, B as BatchOperationsMethods, C as methodRegistryPlugin, D as CustomIdOptions, E as elasticSearchPlugin, F as prefixedId, G as AuditQueryOptions, H as batchOperationsPlugin, I as sequentialId, J as AuditTrailOptions, K as AuditQueryResult, L as cascadePlugin, M as customIdPlugin, N as dateSequentialId, O as DateSequentialIdOptions, P as getNextSequence, Q as AggregateHelpersMethods, R as CacheMethods, S as MethodRegistryRepository, T as ElasticSearchOptions, U as AuditEntry, W as AuditOperation, X as auditTrailPlugin, Y as AuditTrailQuery, Z as auditLogPlugin, _ as observabilityPlugin, a as uniqueField, b as MongoOperationsMethods, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as SequentialIdOptions, k as IdGenerator, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, q as AuditTrailMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MultiTenantOptions, w as fieldFilterPlugin, x as mongoOperationsPlugin, y as multiTenantPlugin, z as cachePlugin } from "../validation-chain.plugin-B0VSdcwa.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, type TenantContext, type TenantStore, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, createTenantContext, 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 AuditTrailQuery, C as cachePlugin, M as auditLogPlugin, N as aggregateHelpersPlugin, S as cascadePlugin, _ as customIdPlugin, a as uniqueField, b as prefixedId, c as createTenantContext, d as observabilityPlugin, f as multiTenantPlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, j as auditTrailPlugin, k as batchOperationsPlugin, l as subdocumentPlugin, m as methodRegistryPlugin, n as blockIf, o as validationChainPlugin, p as mongoOperationsPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as dateSequentialId, x as sequentialId, y as getNextSequence } from "../validation-chain.plugin-
|
|
1
|
+
import { A as AuditTrailQuery, C as cachePlugin, M as auditLogPlugin, N as aggregateHelpersPlugin, S as cascadePlugin, _ as customIdPlugin, a as uniqueField, b as prefixedId, c as createTenantContext, d as observabilityPlugin, f as multiTenantPlugin, g as elasticSearchPlugin, h as fieldFilterPlugin, i as requireField, j as auditTrailPlugin, k as batchOperationsPlugin, l as subdocumentPlugin, m as methodRegistryPlugin, n as blockIf, o as validationChainPlugin, p as mongoOperationsPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as dateSequentialId, x as sequentialId, y as getNextSequence } from "../validation-chain.plugin-Dllv-cml.mjs";
|
|
2
2
|
export { AuditTrailQuery, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
|
|
@@ -2,7 +2,7 @@ import * as _$mongoose from "mongoose";
|
|
|
2
2
|
import { Document, Model, PipelineStage, PopulateOptions, Types } from "mongoose";
|
|
3
3
|
import * as _$_classytic_repo_core_filter0 from "@classytic/repo-core/filter";
|
|
4
4
|
import * as _$_classytic_repo_core_repository0 from "@classytic/repo-core/repository";
|
|
5
|
-
import { DeleteResult, LookupPopulateResult, UpdateManyResult } from "@classytic/repo-core/repository";
|
|
5
|
+
import { DeleteManyResult, DeleteResult, LookupPopulateResult, UpdateManyResult } from "@classytic/repo-core/repository";
|
|
6
6
|
import { ValidationResult } from "@classytic/repo-core/schema";
|
|
7
7
|
|
|
8
8
|
//#region src/query/LookupBuilder.d.ts
|
|
@@ -554,7 +554,25 @@ type NonNullableFields<T> = { [K in keyof T]: NonNullable<T[K]> };
|
|
|
554
554
|
* Create/Update input types from document
|
|
555
555
|
*/
|
|
556
556
|
type CreateInput<TDoc> = Omit<TDoc, '_id' | 'createdAt' | 'updatedAt' | '__v'>;
|
|
557
|
-
|
|
557
|
+
/**
|
|
558
|
+
* Partial-document update patch — the shape `repo.update(id, data)` accepts
|
|
559
|
+
* for its `data` parameter. A `Partial<TDoc>` minus the fields a caller must
|
|
560
|
+
* never set directly (`_id`, `createdAt`, `__v`).
|
|
561
|
+
*
|
|
562
|
+
* **Renamed from `UpdateInput<TDoc>` in 3.11.0** to eliminate a name
|
|
563
|
+
* collision with `@classytic/repo-core/update`'s `UpdateInput` (the
|
|
564
|
+
* `UpdateSpec | Record | Record[]` union consumed by `updateMany` /
|
|
565
|
+
* `findOneAndUpdate`). The legacy name remains as a deprecated alias for
|
|
566
|
+
* one release — remove in 3.12.
|
|
567
|
+
*/
|
|
568
|
+
type UpdatePatch<TDoc> = Partial<Omit<TDoc, '_id' | 'createdAt' | '__v'>>;
|
|
569
|
+
/**
|
|
570
|
+
* @deprecated Renamed to {@link UpdatePatch} in 3.11.0. This alias exists
|
|
571
|
+
* for one release only and will be removed in 3.12. If you actually wanted
|
|
572
|
+
* the bulk/find-and-update union (`UpdateSpec | Record | Record[]`), import
|
|
573
|
+
* `UpdateInput` from `@classytic/repo-core/update` instead.
|
|
574
|
+
*/
|
|
575
|
+
type UpdateInput<TDoc> = UpdatePatch<TDoc>;
|
|
558
576
|
/** Hook execution mode */
|
|
559
577
|
type HookMode = 'sync' | 'async';
|
|
560
578
|
/** Search strategy used by Repository.getAll when `search` is provided */
|
|
@@ -1334,6 +1352,19 @@ interface CascadeOptions {
|
|
|
1334
1352
|
/** HTTP Error with status code */
|
|
1335
1353
|
interface HttpError extends Error {
|
|
1336
1354
|
status: number;
|
|
1355
|
+
/**
|
|
1356
|
+
* Stable machine-readable error code. Hosts can switch on this in catch
|
|
1357
|
+
* blocks instead of grepping the message string. Currently emitted for:
|
|
1358
|
+
* - `SEARCH_NOT_CONFIGURED` — search requested on a repo with no text
|
|
1359
|
+
* index AND no `searchMode: 'regex' | 'auto'` + `searchFields` config.
|
|
1360
|
+
*/
|
|
1361
|
+
code?: string;
|
|
1362
|
+
/**
|
|
1363
|
+
* Free-form structured metadata for diagnostics. Pairs with `code` so
|
|
1364
|
+
* hosts can render a clearer message in their own UI without parsing
|
|
1365
|
+
* the human-readable `message` string. Safe for logs.
|
|
1366
|
+
*/
|
|
1367
|
+
meta?: Record<string, unknown>;
|
|
1337
1368
|
validationErrors?: Array<{
|
|
1338
1369
|
validator: string;
|
|
1339
1370
|
error: string;
|
|
@@ -1400,20 +1431,6 @@ type AllPluginMethods<TDoc> = {
|
|
|
1400
1431
|
setMin(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1401
1432
|
setMax(id: string | ObjectId, field: DocField<TDoc>, value: unknown, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1402
1433
|
atomicUpdate(id: string | ObjectId, operators: Record<string, Record<string, unknown>>, options?: Record<string, unknown>): Promise<TDoc>;
|
|
1403
|
-
updateMany(query: Record<string, unknown>, data: Record<string, unknown>, options?: {
|
|
1404
|
-
session?: unknown;
|
|
1405
|
-
updatePipeline?: boolean;
|
|
1406
|
-
}): Promise<{
|
|
1407
|
-
acknowledged: boolean;
|
|
1408
|
-
matchedCount: number;
|
|
1409
|
-
modifiedCount: number;
|
|
1410
|
-
upsertedCount: number;
|
|
1411
|
-
upsertedId: unknown;
|
|
1412
|
-
}>;
|
|
1413
|
-
deleteMany(query: Record<string, unknown>, options?: Record<string, unknown>): Promise<{
|
|
1414
|
-
acknowledged: boolean;
|
|
1415
|
-
deletedCount: number;
|
|
1416
|
-
}>;
|
|
1417
1434
|
bulkWrite(operations: Record<string, unknown>[], options?: {
|
|
1418
1435
|
session?: unknown;
|
|
1419
1436
|
ordered?: boolean;
|
|
@@ -1493,4 +1510,4 @@ type AllPluginMethods<TDoc> = {
|
|
|
1493
1510
|
*/
|
|
1494
1511
|
type WithPlugins<TDoc, TRepo extends RepositoryInstance = RepositoryInstance> = TRepo & AllPluginMethods<TDoc>;
|
|
1495
1512
|
//#endregion
|
|
1496
|
-
export {
|
|
1513
|
+
export { ReadPreferenceType as $, InferDocument as A, ObjectId as B, EventPayload as C, WithTransactionOptions as Ct, GroupResult as D, IResponseFormatter as Dt, FindOneAndUpdateOptions as E, IRequestContext as Et, Logger as F, PaginationResult as G, OffsetPaginationResult as H, LookupPopulateOptions as I, PluginFunction as J, PartialBy as K, LookupPopulateResult as L, KeysOfType as M, KeysetPaginationOptions as N, HookMode as O, LookupBuilder as Ot, KeysetPaginationResult as P, ReadOptions as Q, MinMaxResult as R, EventHandlers as S, WithPlugins as St, FieldPreset as T, IControllerResponse as Tt, OperationOptions as U, OffsetPaginationOptions as V, PaginationConfig as W, PopulateSpec as X, PluginType as Y, PrioritizedHook as Z, DecodedCursor as _, UpdatePatch as _t, AnyDocument as a, RequiredBy as at, DeleteResult as b, ValidationChainOptions as bt, CacheOperationOptions as c, SoftDeleteFilterMode as ct, CacheableOptions as d, SortDirection as dt, RepositoryContext as et, CascadeOptions as f, SortSpec as ft, CreateOptions as g, UpdateOptions as gt, CreateInput as h, UpdateManyResult as ht, AllPluginMethods as i, RepositoryOptions as it, InferRawDoc as j, HttpError as k, LookupOptions as kt, CacheOptions as l, SoftDeleteOptions as lt, CollationOptions as m, UpdateInput as mt, AggregatePaginationOptions as n, RepositoryInstance as nt, AnyModel as o, SelectSpec as ot, CascadeRelation as p, Strict as pt, Plugin as q, AggregatePaginationResult as r, RepositoryOperation as rt, CacheAdapter as s, SessionOptions as st, AggregateOptions as t, RepositoryEvent as tt, CacheStats as u, SoftDeleteRepository as ut, DeepPartial as v, UpdateWithValidationResult as vt, EventPhase as w, IController as wt, DocField as x, ValidatorDefinition as xt, DeleteManyResult as y, UserContext as yt, NonNullableFields as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
2
|
import { r as warn } from "./logger-DJ7egMnd.mjs";
|
|
3
|
-
import { t as createError } from "./error-
|
|
3
|
+
import { t as createError } from "./error-B00pI7dV.mjs";
|
|
4
4
|
//#region src/query/LookupBuilder.ts
|
|
5
5
|
/** Stages that are never valid inside a $lookup pipeline */
|
|
6
6
|
const BLOCKED_PIPELINE_STAGES = [
|
package/dist/utils/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as createFieldPreset, c as getMongooseProjection, i as configureLogger, l as createError, n as buildCrudSchemasFromMongooseSchema, o as filterResponseData, r as createMemoryCache, s as getFieldsForUser, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-
|
|
1
|
+
import { X as PopulateSpec, ft as SortSpec, ot as SelectSpec } from "../types-Dc2aDVUi.mjs";
|
|
2
|
+
import { a as createFieldPreset, c as getMongooseProjection, i as configureLogger, l as createError, n as buildCrudSchemasFromMongooseSchema, o as filterResponseData, r as createMemoryCache, s as getFieldsForUser, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-DXxjFkLB.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/cache-keys.d.ts
|
|
5
5
|
/**
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as configureLogger } from "../logger-DJ7egMnd.mjs";
|
|
2
|
-
import { t as createError } from "../error-
|
|
2
|
+
import { t as createError } from "../error-B00pI7dV.mjs";
|
|
3
3
|
import { n as isObjectIdInstance, r as isValidIdForType, t as getSchemaIdType } from "../id-resolution-e4BT9zAV.mjs";
|
|
4
4
|
import { a as byIdKey, c as listQueryKey, i as getMongooseProjection, l as modelPattern, n as filterResponseData, o as byQueryKey, r as getFieldsForUser, s as listPattern, t as createFieldPreset, u as versionKey } from "../field-selection-dI0m4RBs.mjs";
|
|
5
5
|
import { n as buildCrudSchemasFromMongooseSchema, r as createMemoryCache, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-D1sdCOmj.mjs";
|
package/dist/{validation-chain.plugin-BYJo0Y6g.d.mts → validation-chain.plugin-B0VSdcwa.d.mts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as ObjectId, F as Logger, H as OffsetPaginationResult, T as FieldPreset, X as PopulateSpec, bt as ValidationChainOptions, et as RepositoryContext, f as CascadeOptions, ft as SortSpec, l as CacheOptions, lt as SoftDeleteOptions, nt as RepositoryInstance, ot as SelectSpec, q as Plugin, u as CacheStats, xt as ValidatorDefinition } from "./types-Dc2aDVUi.mjs";
|
|
2
2
|
import mongoose from "mongoose";
|
|
3
3
|
import { BulkWriteResult } from "@classytic/repo-core/repository";
|
|
4
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -245,7 +245,7 @@ interface AuditTrailMethods {
|
|
|
245
245
|
//#endregion
|
|
246
246
|
//#region src/plugins/batch-operations.plugin.d.ts
|
|
247
247
|
/**
|
|
248
|
-
* Batch operations plugin
|
|
248
|
+
* Batch operations plugin.
|
|
249
249
|
*
|
|
250
250
|
* @example
|
|
251
251
|
* const repo = new Repository(Model, [
|
|
@@ -253,47 +253,15 @@ interface AuditTrailMethods {
|
|
|
253
253
|
* batchOperationsPlugin(),
|
|
254
254
|
* ]);
|
|
255
255
|
*
|
|
256
|
+
* // updateMany + deleteMany are primitives on Repository — no plugin needed.
|
|
256
257
|
* await repo.updateMany({ status: 'pending' }, { status: 'active' });
|
|
257
258
|
* await repo.deleteMany({ status: 'deleted' });
|
|
259
|
+
*
|
|
260
|
+
* // bulkWrite is what this plugin contributes.
|
|
261
|
+
* await repo.bulkWrite([...ops]);
|
|
258
262
|
*/
|
|
259
263
|
declare function batchOperationsPlugin(): Plugin;
|
|
260
264
|
interface BatchOperationsMethods {
|
|
261
|
-
/**
|
|
262
|
-
* Update multiple documents matching the query
|
|
263
|
-
* @param query - Query to match documents
|
|
264
|
-
* @param data - Update data
|
|
265
|
-
* @param options - Operation options
|
|
266
|
-
* @returns Update result with matchedCount, modifiedCount, etc.
|
|
267
|
-
*/
|
|
268
|
-
updateMany(query: Record<string, unknown>, data: Record<string, unknown>, options?: {
|
|
269
|
-
session?: unknown;
|
|
270
|
-
updatePipeline?: boolean;
|
|
271
|
-
}): Promise<{
|
|
272
|
-
acknowledged: boolean;
|
|
273
|
-
matchedCount: number;
|
|
274
|
-
modifiedCount: number;
|
|
275
|
-
upsertedCount: number;
|
|
276
|
-
upsertedId: unknown;
|
|
277
|
-
}>;
|
|
278
|
-
/**
|
|
279
|
-
* Delete multiple documents matching the query.
|
|
280
|
-
*
|
|
281
|
-
* Defaults to soft delete when `softDeletePlugin` is wired, physical delete
|
|
282
|
-
* otherwise. Pass `{ mode: 'hard' }` for GDPR / admin cleanup — multi-tenant
|
|
283
|
-
* scoping and audit hooks still fire.
|
|
284
|
-
*
|
|
285
|
-
* @param query - Query to match documents (must be non-empty)
|
|
286
|
-
* @param options - Operation options (session, mode, tenant keys)
|
|
287
|
-
* @returns Delete result with deletedCount
|
|
288
|
-
*/
|
|
289
|
-
deleteMany(query: Record<string, unknown>, options?: {
|
|
290
|
-
session?: unknown;
|
|
291
|
-
mode?: 'hard' | 'soft';
|
|
292
|
-
[key: string]: unknown;
|
|
293
|
-
}): Promise<{
|
|
294
|
-
acknowledged: boolean;
|
|
295
|
-
deletedCount: number;
|
|
296
|
-
}>;
|
|
297
265
|
/**
|
|
298
266
|
* Execute heterogeneous bulk write operations in a single database call.
|
|
299
267
|
* Supports insertOne, updateOne, updateMany, deleteOne, deleteMany, replaceOne.
|