@classytic/mongokit 3.12.0 → 3.13.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 +126 -4
- package/dist/{PaginationEngine-BDaAsyPn.mjs → PaginationEngine-CfQRM1yz.mjs} +16 -16
- package/dist/Repository-d5gWSROf.mjs +3603 -0
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +1 -1
- package/dist/adapter/index.d.mts +190 -0
- package/dist/adapter/index.mjs +2 -0
- package/dist/adapter-DTDMnUOH.mjs +158 -0
- package/dist/ai/index.d.mts +1 -1
- package/dist/ai/index.mjs +1 -1
- package/dist/better-auth/index.d.mts +149 -0
- package/dist/better-auth/index.mjs +81 -0
- package/dist/field-selection-Br3WPOEb.mjs +99 -0
- package/dist/{index-D9cORR-o.d.mts → index-BbHaKwi5.d.mts} +33 -13
- package/dist/index.d.mts +690 -30
- package/dist/index.mjs +240 -17
- package/dist/{logger-8-VS1za6.mjs → logger-DprijP5h.mjs} +1 -5
- package/dist/{mongooseToJsonSchema-B187ufOP.mjs → mongooseToJsonSchema-BYbG894y.mjs} +1 -1
- package/dist/{mongooseToJsonSchema-rtkdbBhf.d.mts → mongooseToJsonSchema-BgRAaXX-.d.mts} +2 -1
- package/dist/pagination/PaginationEngine.d.mts +2 -2
- package/dist/pagination/PaginationEngine.mjs +1 -1
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.mjs +2 -2
- package/dist/query/primitives/coercion.d.mts +1 -1
- package/dist/query/primitives/coercion.mjs +1 -1
- package/dist/query/primitives/indexes.d.mts +1 -1
- package/dist/{types-DXscZnLu.d.mts → types-BbaPZleN.d.mts} +371 -112
- package/dist/{update-CDxPtpsk.mjs → update-C-3viiw1.mjs} +112 -28
- package/dist/utils/index.d.mts +2 -91
- package/dist/utils/index.mjs +5 -5
- package/dist/validation-chain.plugin-BLVp_Pw2.mjs +2399 -0
- package/dist/{validation-chain.plugin-CH-xPoKM.d.mts → validation-chain.plugin-CAPYCj_T.d.mts} +212 -80
- package/package.json +20 -3
- package/dist/field-selection-dI0m4RBs.mjs +0 -221
- package/dist/validation-chain.plugin-BicIgzzt.mjs +0 -4970
- /package/dist/{coercion-oM8G4b6m.d.mts → coercion-TRMmR49h.d.mts} +0 -0
- /package/dist/{id-resolution-e4BT9zAV.mjs → id-resolution-B0Odvvou.mjs} +0 -0
- /package/dist/{indexes-C26GNZRU.d.mts → indexes-CgOF7Wjd.d.mts} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,91 @@
|
|
|
1
|
-
import { b as LookupBuilder } from "./update-
|
|
2
|
-
import {
|
|
1
|
+
import { b as LookupBuilder, x as compileFilterToMongo } from "./update-C-3viiw1.mjs";
|
|
2
|
+
import { n as warn, t as configureLogger } from "./logger-DprijP5h.mjs";
|
|
3
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 {
|
|
6
|
-
import { t as PaginationEngine } from "./PaginationEngine-
|
|
5
|
+
import { a as withTransaction, c as MUTATING_OPERATIONS, d as operationsByPolicyKey, i as isTransactionUnsupported, l as OP_REGISTRY, n as Repository, o as AggregationBuilder, r as batchTransaction, s as ALL_OPERATIONS, t as HOOK_PRIORITY, u as READ_OPERATIONS } from "./Repository-d5gWSROf.mjs";
|
|
6
|
+
import { t as PaginationEngine } from "./PaginationEngine-CfQRM1yz.mjs";
|
|
7
|
+
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, f as adminBypass, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "./validation-chain.plugin-BLVp_Pw2.mjs";
|
|
8
|
+
import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-Br3WPOEb.mjs";
|
|
7
9
|
import { isGeoOperator, parseGeoFilter } from "./query/primitives/geo.mjs";
|
|
8
|
-
import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-dI0m4RBs.mjs";
|
|
9
10
|
import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
|
|
10
11
|
import { extractSchemaIndexes } from "./query/primitives/indexes.mjs";
|
|
11
|
-
import { n as buildCrudSchemasFromMongooseSchema, r as createMemoryCache, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-
|
|
12
|
+
import { n as buildCrudSchemasFromMongooseSchema, r as createMemoryCache, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-BYbG894y.mjs";
|
|
13
|
+
import { isControlParam } from "@classytic/repo-core/query-parser";
|
|
12
14
|
//#region src/query/QueryParser.ts
|
|
13
15
|
/**
|
|
16
|
+
* Modern Query Parser - URL to MongoDB Query Transpiler
|
|
17
|
+
*
|
|
18
|
+
* Next-generation query parser that converts URL parameters to MongoDB aggregation pipelines.
|
|
19
|
+
* Smarter than Prisma/tRPC for MongoDB with support for:
|
|
20
|
+
* - Custom field lookups ($lookup)
|
|
21
|
+
* - Complex filtering with operators
|
|
22
|
+
* - Full-text search
|
|
23
|
+
* - Aggregations via URL
|
|
24
|
+
* - Security hardening
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Simple usage
|
|
29
|
+
* const parser = new QueryParser();
|
|
30
|
+
* const query = parser.parse(req.query);
|
|
31
|
+
*
|
|
32
|
+
* // URL: ?status=active&lookup[department]=slug&sort=-createdAt&page=1&limit=20
|
|
33
|
+
* // Result: Complete MongoDB query with $lookup, filters, sort, pagination
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* ## SECURITY CONSIDERATIONS FOR PRODUCTION
|
|
37
|
+
*
|
|
38
|
+
* ### Aggregation Security (enableAggregations option)
|
|
39
|
+
*
|
|
40
|
+
* **IMPORTANT:** The `enableAggregations` option exposes powerful MongoDB aggregation
|
|
41
|
+
* pipeline capabilities via URL parameters. While this feature includes sanitization
|
|
42
|
+
* (blocks $where, $function, $accumulator), it should be used with caution:
|
|
43
|
+
*
|
|
44
|
+
* **Recommended security practices:**
|
|
45
|
+
* 1. **Disable by default for public endpoints:**
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const parser = new QueryParser({
|
|
48
|
+
* enableAggregations: false // Default: disabled
|
|
49
|
+
* });
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* 2. **Use per-route allowlists for trusted clients:**
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // Admin/internal routes only
|
|
55
|
+
* if (req.user?.role === 'admin') {
|
|
56
|
+
* const allowedStages = ['$match', '$project', '$sort', '$limit'];
|
|
57
|
+
* // Validate aggregate parameter against allowlist
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* 3. **Validate stage structure:** Even with sanitization, complex pipelines can
|
|
62
|
+
* cause performance issues. Consider limiting:
|
|
63
|
+
* - Number of pipeline stages (e.g., max 5)
|
|
64
|
+
* - Specific allowed operators per stage
|
|
65
|
+
* - Allowed fields in $project/$match
|
|
66
|
+
*
|
|
67
|
+
* 4. **Monitor resource usage:** Aggregation pipelines can be expensive.
|
|
68
|
+
* Use MongoDB profiling to track slow operations.
|
|
69
|
+
*
|
|
70
|
+
* ### Lookup Security
|
|
71
|
+
*
|
|
72
|
+
* Lookup pipelines are sanitized by default:
|
|
73
|
+
* - Dangerous stages blocked ($out, $merge, $unionWith, $collStats, $currentOp, $listSessions)
|
|
74
|
+
* - Dangerous operators blocked inside $match/$addFields/$set ($where, $function, $accumulator, $expr)
|
|
75
|
+
* - Optional collection whitelist via `allowedLookupCollections`
|
|
76
|
+
* For maximum security, use per-collection field allowlists in your controller layer.
|
|
77
|
+
*
|
|
78
|
+
* ### Filter Security
|
|
79
|
+
*
|
|
80
|
+
* All filters are sanitized:
|
|
81
|
+
* - Dangerous operators blocked ($where, $function, $accumulator, $expr)
|
|
82
|
+
* - Regex patterns validated (ReDoS protection)
|
|
83
|
+
* - Max filter depth enforced (prevents filter bombs)
|
|
84
|
+
* - Max limit enforced (prevents resource exhaustion)
|
|
85
|
+
*
|
|
86
|
+
* @see {@link https://github.com/classytic/mongokit/blob/main/docs/SECURITY.md}
|
|
87
|
+
*/
|
|
88
|
+
/**
|
|
14
89
|
* Top-level query parameters that mongokit handles outside the filter
|
|
15
90
|
* pipeline. Used by `_handleBracketSyntax` to detect a common typo where a
|
|
16
91
|
* caller wrote `?filters[limit]=5` instead of `?limit=5` and the qs parser
|
|
@@ -616,13 +691,7 @@ var QueryParser = class {
|
|
|
616
691
|
warn(`[mongokit] Blocked dangerous operator: ${key}`);
|
|
617
692
|
continue;
|
|
618
693
|
}
|
|
619
|
-
if ([
|
|
620
|
-
"page",
|
|
621
|
-
"limit",
|
|
622
|
-
"sort",
|
|
623
|
-
"populate",
|
|
624
|
-
"search",
|
|
625
|
-
"select",
|
|
694
|
+
if (isControlParam(key) || [
|
|
626
695
|
"lean",
|
|
627
696
|
"includeDeleted",
|
|
628
697
|
"lookup",
|
|
@@ -902,17 +971,26 @@ var QueryParser = class {
|
|
|
902
971
|
/**
|
|
903
972
|
* Recursively sanitize expression objects, blocking dangerous operators
|
|
904
973
|
* like $where, $function, $accumulator inside $addFields/$set stages.
|
|
974
|
+
*
|
|
975
|
+
* Depth-guarded — same protection `_sanitizeMatchConfig` ships, since
|
|
976
|
+
* a hostile `$cond`/`$switch` chain can recurse arbitrarily deep and
|
|
977
|
+
* exhaust JS stack. Without the guard, this is a one-liner DoS against
|
|
978
|
+
* any host that exposes pipeline parsing to untrusted callers.
|
|
905
979
|
*/
|
|
906
|
-
_sanitizeExpressions(config) {
|
|
980
|
+
_sanitizeExpressions(config, depth = 0) {
|
|
981
|
+
if (depth > this.options.maxFilterDepth) {
|
|
982
|
+
warn(`[mongokit] pipeline expression sanitize depth ${depth} exceeds maximum ${this.options.maxFilterDepth}, truncating branch`);
|
|
983
|
+
return {};
|
|
984
|
+
}
|
|
907
985
|
const sanitized = {};
|
|
908
986
|
for (const [key, value] of Object.entries(config)) {
|
|
909
987
|
if (this.dangerousOperators.includes(key)) {
|
|
910
988
|
warn(`[mongokit] Blocked dangerous operator in pipeline expression: ${key}`);
|
|
911
989
|
continue;
|
|
912
990
|
}
|
|
913
|
-
if (value && typeof value === "object" && !Array.isArray(value)) sanitized[key] = this._sanitizeExpressions(value);
|
|
991
|
+
if (value && typeof value === "object" && !Array.isArray(value)) sanitized[key] = this._sanitizeExpressions(value, depth + 1);
|
|
914
992
|
else if (Array.isArray(value)) sanitized[key] = value.map((item) => {
|
|
915
|
-
if (item && typeof item === "object" && !Array.isArray(item)) return this._sanitizeExpressions(item);
|
|
993
|
+
if (item && typeof item === "object" && !Array.isArray(item)) return this._sanitizeExpressions(item, depth + 1);
|
|
916
994
|
return item;
|
|
917
995
|
});
|
|
918
996
|
else sanitized[key] = value;
|
|
@@ -985,6 +1063,151 @@ var QueryParser = class {
|
|
|
985
1063
|
}
|
|
986
1064
|
};
|
|
987
1065
|
//#endregion
|
|
1066
|
+
//#region src/utils/repo-options.ts
|
|
1067
|
+
/**
|
|
1068
|
+
* Forward request-scoped context fields into a mongokit options bag.
|
|
1069
|
+
*
|
|
1070
|
+
* Multi-tenant scoping, audit attribution, and transaction threading
|
|
1071
|
+
* all read their inputs from the **options** argument of every repo
|
|
1072
|
+
* method — `multiTenantPlugin` looks for `organizationId`, the audit
|
|
1073
|
+
* plugins read `userId` / `user`, and `withTransaction` honors
|
|
1074
|
+
* `session`. Consumers were repeatedly hand-rolling:
|
|
1075
|
+
*
|
|
1076
|
+
* ```ts
|
|
1077
|
+
* await repo.update(id, data, {
|
|
1078
|
+
* organizationId: ctx.organizationId,
|
|
1079
|
+
* userId: ctx.userId,
|
|
1080
|
+
* session: ctx.session,
|
|
1081
|
+
* });
|
|
1082
|
+
* ```
|
|
1083
|
+
*
|
|
1084
|
+
* — sometimes correctly forwarding all three, sometimes only one,
|
|
1085
|
+
* sometimes constructing `Types.ObjectId(orgId)` manually because the
|
|
1086
|
+
* caller didn't trust `multiTenantPlugin` to handle the cast (it does).
|
|
1087
|
+
* The result was inconsistent forwarding across repos, with several
|
|
1088
|
+
* silent tenant-leak shapes traced back to a forgotten field.
|
|
1089
|
+
*
|
|
1090
|
+
* `repoOptionsFromCtx(ctx)` is the canonical extractor. Pass it the
|
|
1091
|
+
* request context (whatever shape your framework hands you) and it
|
|
1092
|
+
* returns the subset of fields mongokit's plugins read. Unknown ctx
|
|
1093
|
+
* keys are NOT forwarded — the options bag stays narrow and explicit.
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```ts
|
|
1097
|
+
* import { repoOptionsFromCtx } from '@classytic/mongokit';
|
|
1098
|
+
*
|
|
1099
|
+
* await orderRepo.update(id, data, repoOptionsFromCtx(ctx));
|
|
1100
|
+
* await orderRepo.claim(id, { from: 'pending', to: 'shipped' }, {}, repoOptionsFromCtx(ctx));
|
|
1101
|
+
* ```
|
|
1102
|
+
*
|
|
1103
|
+
* @example Spreading + adding kit-specific options
|
|
1104
|
+
* ```ts
|
|
1105
|
+
* await orderRepo.findOneAndUpdate(filter, update, {
|
|
1106
|
+
* ...repoOptionsFromCtx(ctx),
|
|
1107
|
+
* returnDocument: 'after',
|
|
1108
|
+
* upsert: true,
|
|
1109
|
+
* });
|
|
1110
|
+
* ```
|
|
1111
|
+
*
|
|
1112
|
+
* The fields read (all optional — extracted only when present and not
|
|
1113
|
+
* `undefined`):
|
|
1114
|
+
*
|
|
1115
|
+
* - `organizationId` — multi-tenant scope key. The
|
|
1116
|
+
* `multiTenantPlugin` casts to `ObjectId` automatically when
|
|
1117
|
+
* configured with `fieldType: 'objectId'`; do NOT pre-cast.
|
|
1118
|
+
* - `userId` / `user` — audit attribution (audit-log + audit-trail
|
|
1119
|
+
* plugins read these for the `who` column).
|
|
1120
|
+
* - `session` — mongoose `ClientSession` for transaction threading.
|
|
1121
|
+
* - `requestId` — observability correlation id.
|
|
1122
|
+
*
|
|
1123
|
+
* Fields beyond this set should be added inline at the call site —
|
|
1124
|
+
* `repoOptionsFromCtx` deliberately stays narrow so adding a new
|
|
1125
|
+
* convention to the canonical set is a deliberate API decision, not
|
|
1126
|
+
* a quiet drift.
|
|
1127
|
+
*/
|
|
1128
|
+
function repoOptionsFromCtx(ctx) {
|
|
1129
|
+
if (!ctx) return {};
|
|
1130
|
+
const out = {};
|
|
1131
|
+
if (ctx.organizationId !== void 0) out.organizationId = ctx.organizationId;
|
|
1132
|
+
if (ctx.userId !== void 0) out.userId = ctx.userId;
|
|
1133
|
+
if (ctx.user !== void 0) out.user = ctx.user;
|
|
1134
|
+
if (ctx.session !== void 0) out.session = ctx.session;
|
|
1135
|
+
if (ctx.requestId !== void 0) out.requestId = ctx.requestId;
|
|
1136
|
+
return out;
|
|
1137
|
+
}
|
|
1138
|
+
/**
|
|
1139
|
+
* Build a typed extractor for **consumer-defined** ctx → options
|
|
1140
|
+
* forwarding. Same conceptual shape as `repoOptionsFromCtx`, but the
|
|
1141
|
+
* caller declares the field set so domain-package fields beyond
|
|
1142
|
+
* mongokit's bundled-plugin keys land too.
|
|
1143
|
+
*
|
|
1144
|
+
* Across the classytic codebase, ~6 packages (commission, supplier-
|
|
1145
|
+
* performance, pos, yard, order, plus implicit in leave/payrun/
|
|
1146
|
+
* muster/people) ship a hand-rolled 15-line `repo-options.ts` doing
|
|
1147
|
+
* the same shape — drift is inevitable, "I forgot to forward
|
|
1148
|
+
* `correlationId`" is a recurring bug class. This builder eliminates
|
|
1149
|
+
* the boilerplate and pins the field list at the type level so
|
|
1150
|
+
* adding a new canonical field is a single-line edit.
|
|
1151
|
+
*
|
|
1152
|
+
* **Type-safe field declaration.** The `fields` array is constrained
|
|
1153
|
+
* to `keyof TCtx & string`, so a typo in a field name is a compile
|
|
1154
|
+
* error rather than a silent absent-key. The returned extractor's
|
|
1155
|
+
* output keys are inferred from the input field tuple — you can
|
|
1156
|
+
* destructure with full autocomplete.
|
|
1157
|
+
*
|
|
1158
|
+
* **Difference from `repoOptionsFromCtx`.** That helper hardcodes the
|
|
1159
|
+
* fields **mongokit's bundled plugins** read (`organizationId`,
|
|
1160
|
+
* `userId`, `user`, `session`, `requestId`). Use it when those are
|
|
1161
|
+
* sufficient. Reach for `createOptionsExtractor` when your domain has
|
|
1162
|
+
* its own canonical fields (`actorRef`, `actorKind`, `correlationId`,
|
|
1163
|
+
* `idempotencyKey`, `sagaRunId`, ...) that should also forward.
|
|
1164
|
+
*
|
|
1165
|
+
* @example Per-package canonical extractor
|
|
1166
|
+
* ```ts
|
|
1167
|
+
* import { createOptionsExtractor } from '@classytic/mongokit';
|
|
1168
|
+
*
|
|
1169
|
+
* type CommissionCtx = {
|
|
1170
|
+
* organizationId: string;
|
|
1171
|
+
* actorRef: string;
|
|
1172
|
+
* actorKind: 'user' | 'system';
|
|
1173
|
+
* correlationId: string;
|
|
1174
|
+
* session?: ClientSession;
|
|
1175
|
+
* idempotencyKey?: string;
|
|
1176
|
+
* };
|
|
1177
|
+
*
|
|
1178
|
+
* export const repoOptionsFromCtx = createOptionsExtractor<CommissionCtx>([
|
|
1179
|
+
* 'organizationId',
|
|
1180
|
+
* 'actorRef',
|
|
1181
|
+
* 'actorKind',
|
|
1182
|
+
* 'correlationId',
|
|
1183
|
+
* 'session',
|
|
1184
|
+
* 'idempotencyKey',
|
|
1185
|
+
* ]);
|
|
1186
|
+
*
|
|
1187
|
+
* // Use:
|
|
1188
|
+
* await commissionRepo.update(id, data, repoOptionsFromCtx(ctx));
|
|
1189
|
+
* ```
|
|
1190
|
+
*
|
|
1191
|
+
* @param fields - The canonical option keys to extract from ctx.
|
|
1192
|
+
* Must be `(keyof TCtx & string)[]` — TypeScript prevents typos at
|
|
1193
|
+
* the declaration site.
|
|
1194
|
+
* @returns An extractor function `(ctx: TCtx | null | undefined) → Record<string, unknown>`
|
|
1195
|
+
* that omits absent/undefined keys (so spreading into a parent
|
|
1196
|
+
* options bag never erases inherited values).
|
|
1197
|
+
*/
|
|
1198
|
+
function createOptionsExtractor(fields) {
|
|
1199
|
+
const frozen = Object.freeze([...fields]);
|
|
1200
|
+
return function extractRepoOptions(ctx) {
|
|
1201
|
+
if (!ctx) return {};
|
|
1202
|
+
const out = {};
|
|
1203
|
+
for (const field of frozen) {
|
|
1204
|
+
const v = ctx[field];
|
|
1205
|
+
if (v !== void 0) out[field] = v;
|
|
1206
|
+
}
|
|
1207
|
+
return out;
|
|
1208
|
+
};
|
|
1209
|
+
}
|
|
1210
|
+
//#endregion
|
|
988
1211
|
//#region src/index.ts
|
|
989
1212
|
/**
|
|
990
1213
|
* Factory function to create a repository instance
|
|
@@ -1001,4 +1224,4 @@ function createRepository(Model, plugins = [], paginationConfig = {}, options =
|
|
|
1001
1224
|
}
|
|
1002
1225
|
var src_default = Repository;
|
|
1003
1226
|
//#endregion
|
|
1004
|
-
export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MUTATING_OPERATIONS, OP_REGISTRY, PaginationEngine, QueryParser, READ_OPERATIONS, Repository, actions_exports as actions, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, configureLogger, createError, createFieldPreset, createMemoryCache, createRepository, createTenantContext, customIdPlugin, dateSequentialId, src_default as default, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, immutableField, isDuplicateKeyError, isTransactionUnsupported, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
|
|
1227
|
+
export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MUTATING_OPERATIONS, OP_REGISTRY, PaginationEngine, QueryParser, READ_OPERATIONS, Repository, actions_exports as actions, adminBypass, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, src_default as default, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, immutableField, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
|
|
@@ -22,9 +22,5 @@ function configureLogger(config) {
|
|
|
22
22
|
function warn(message, ...args) {
|
|
23
23
|
current.warn(message, ...args);
|
|
24
24
|
}
|
|
25
|
-
/** Emit debug info — only visible when debug is enabled */
|
|
26
|
-
function debug(message, ...args) {
|
|
27
|
-
current.debug(message, ...args);
|
|
28
|
-
}
|
|
29
25
|
//#endregion
|
|
30
|
-
export {
|
|
26
|
+
export { warn as n, configureLogger as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as isObjectIdInstance } from "./id-resolution-
|
|
1
|
+
import { n as isObjectIdInstance } from "./id-resolution-B0Odvvou.mjs";
|
|
2
2
|
import mongoose from "mongoose";
|
|
3
3
|
import { applyFieldRules, collectFieldsToOmit } from "@classytic/repo-core/schema";
|
|
4
4
|
//#region src/utils/memory-cache.ts
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as FieldPreset, gt as UserContext } from "./types-BbaPZleN.mjs";
|
|
2
2
|
import mongoose, { Schema } from "mongoose";
|
|
3
|
+
import { CacheAdapter } from "@classytic/repo-core/cache";
|
|
3
4
|
import { CrudSchemas, SchemaBuilderOptions } from "@classytic/repo-core/schema";
|
|
4
5
|
import { HttpError } from "@classytic/repo-core/errors";
|
|
5
6
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as KeysetPaginationOptions, U as PaginationConfig, V as OffsetPaginationOptions, i as AnyDocument, n as AggregatePaginationOptions } from "../types-BbaPZleN.mjs";
|
|
2
2
|
import { Model } from "mongoose";
|
|
3
3
|
import { AggregatePaginationResult, KeysetPaginationResult, OffsetPaginationResult } from "@classytic/repo-core/pagination";
|
|
4
4
|
|
|
@@ -52,7 +52,7 @@ declare class PaginationEngine<TDoc = AnyDocument> {
|
|
|
52
52
|
* page: 1,
|
|
53
53
|
* limit: 20
|
|
54
54
|
* });
|
|
55
|
-
* console.log(result.
|
|
55
|
+
* console.log(result.data, result.total, result.hasNext);
|
|
56
56
|
*/
|
|
57
57
|
paginate(options?: OffsetPaginationOptions): Promise<OffsetPaginationResult<TDoc>>;
|
|
58
58
|
/**
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as PaginationEngine } from "../PaginationEngine-
|
|
1
|
+
import { t as PaginationEngine } from "../PaginationEngine-CfQRM1yz.mjs";
|
|
2
2
|
export { PaginationEngine };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type AggregateHelpersMethods, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type
|
|
1
|
+
import { $ as AuditQueryResult, A as elasticSearchPlugin, B as sequentialId, C as MethodRegistryRepository, D as leasePlugin, E as LeasePluginOptions, F as SequentialIdOptions, G as RepositoryCachePluginOptions, H as CacheAdapter, I as customIdPlugin, K as cachePlugin, L as dateSequentialId, M as DateSequentialIdOptions, N as IdGenerator, O as fieldFilterPlugin, P as PrefixedIdOptions, Q as AuditQueryOptions, R as getNextSequence, S as mongoOperationsPlugin, T as LeaseMethods, U as CacheOptions, V as cascadePlugin, W as RepositoryCacheHandle, X as AuditEntry, Y as batchOperationsPlugin, Z as AuditOperation, _ as observabilityPlugin, a as uniqueField, at as AggregateHelpersMethods, b as multiTenantPlugin, c as TenantContext, d as SubdocumentMethods, et as AuditTrailMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, it as auditLogPlugin, j as CustomIdOptions, k as ElasticSearchOptions, l as TenantStore, m as softDeletePlugin, n as blockIf, nt as AuditTrailQuery, o as validationChainPlugin, ot as aggregateHelpersPlugin, p as SoftDeleteMethods, q as BatchOperationsMethods, r as immutableField, rt as auditTrailPlugin, s as timestampPlugin, t as autoInject, tt as AuditTrailOptions, u as createTenantContext, v as MultiTenantOptions, w as methodRegistryPlugin, x as MongoOperationsMethods, z as prefixedId } from "../validation-chain.plugin-CAPYCj_T.mjs";
|
|
2
|
+
export { type AggregateHelpersMethods, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type CacheAdapter, type CacheOptions, type CustomIdOptions, type DateSequentialIdOptions, type ElasticSearchOptions, type IdGenerator, type LeaseMethods, type LeasePluginOptions, type MethodRegistryRepository, type MongoOperationsMethods, type MultiTenantOptions, type ObservabilityOptions, type OperationMetric, type PrefixedIdOptions, type RepositoryCacheHandle, type RepositoryCachePluginOptions, 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, leasePlugin, 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
|
|
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 };
|
|
1
|
+
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "../validation-chain.plugin-BLVp_Pw2.mjs";
|
|
2
|
+
export { AuditTrailQuery, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as coerceHeuristic, i as coerceFieldValue, n as SchemaPathsLike, o as coerceToType, r as buildFieldTypeMap, s as normalizeMongooseType, t as FieldType } from "../../coercion-
|
|
1
|
+
import { a as coerceHeuristic, i as coerceFieldValue, n as SchemaPathsLike, o as coerceToType, r as buildFieldTypeMap, s as normalizeMongooseType, t as FieldType } from "../../coercion-TRMmR49h.mjs";
|
|
2
2
|
export { FieldType, SchemaPathsLike, buildFieldTypeMap, coerceFieldValue, coerceHeuristic, coerceToType, normalizeMongooseType };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SchemaIndexes, r as extractSchemaIndexes, t as IndexableSchema } from "../../indexes-
|
|
1
|
+
import { n as SchemaIndexes, r as extractSchemaIndexes, t as IndexableSchema } from "../../indexes-CgOF7Wjd.mjs";
|
|
2
2
|
export { IndexableSchema, SchemaIndexes, extractSchemaIndexes };
|