@classytic/mongokit 3.29.0 → 3.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/{PaginationEngine-CczbvCAq.mjs → PaginationEngine-CuONvwCM.mjs} +21 -1
- package/dist/{create-repository-D4ZU94b3.d.mts → Repository-BAzymuOz.d.mts} +31 -58
- package/dist/{Repository-DThvFCaV.mjs → Repository-BQ3FEnOa.mjs} +352 -56
- package/dist/actions/index.d.mts +1 -1
- package/dist/actions/index.mjs +1 -1
- package/dist/adapter/index.mjs +1 -1
- package/dist/{adapter-CLvUHiTW.mjs → adapter-BitHg-CN.mjs} +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/better-auth/index.d.mts +13 -0
- package/dist/better-auth/index.mjs +76 -6
- package/dist/{create-repository-uhKt_oUT.mjs → create-repository-BOTVMsIg.mjs} +3 -2
- package/dist/create-repository-mEdfH9sz.d.mts +54 -0
- package/dist/{index-DceInCTX.d.mts → index-Beyr1r4d.d.mts} +1 -1
- package/dist/index.d.mts +305 -43
- package/dist/index.mjs +118 -11
- package/dist/kernel-conformance/index.d.mts +217 -0
- package/dist/kernel-conformance/index.mjs +603 -0
- package/dist/method-registry.plugin-DblM7V6j.mjs +112 -0
- package/dist/model-registry-ClKtWiHa.mjs +67 -0
- package/dist/{mongooseToJsonSchema-CByt1VhQ.mjs → mongooseToJsonSchema-DKbnKduN.mjs} +14 -3
- package/dist/{multi-tenant.plugin-DVyVGREb.d.mts → multi-tenant.plugin-2VtSSm1Y.d.mts} +1 -1
- package/dist/{operations-C8IcCHF9.d.mts → operations-CuzX9m2Z.d.mts} +42 -3
- package/dist/outbox/index.d.mts +63 -0
- package/dist/outbox/index.mjs +239 -0
- package/dist/pagination/PaginationEngine.mjs +1 -1
- package/dist/{plugin-options-vFufQZMZ.d.mts → plugin-options-BsFH0sTi.d.mts} +1 -1
- package/dist/plugins/index.d.mts +4 -4
- package/dist/plugins/index.mjs +3 -2
- package/dist/{repository-DCHRWRXw.d.mts → repository-Q16ErTu8.d.mts} +19 -1
- package/dist/testkit/index.d.mts +8 -1
- package/dist/testkit/index.mjs +1 -1
- package/dist/{timestamp.plugin-CFL6LlYZ.mjs → timestamp.plugin-i9Qxm6kn.mjs} +32 -143
- package/dist/{to-plain-DkF5px0R.d.mts → to-plain-BuX1RUZV.d.mts} +12 -4
- package/dist/{update-CI2NdAW6.mjs → update-DAO5STDv.mjs} +62 -7
- package/dist/utils/index.d.mts +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/{validation-chain.plugin-BLecaKa0.d.mts → validation-chain.plugin-BSshLJTA.d.mts} +3 -3
- package/dist/{validation-chain.plugin-CwOcUJC1.mjs → validation-chain.plugin-CpcB6dOd.mjs} +4 -3
- package/package.json +193 -187
|
@@ -58,6 +58,19 @@ interface RegisterBetterAuthStubsOptions {
|
|
|
58
58
|
usePlural?: boolean;
|
|
59
59
|
/** Per-collection model name override (mirrors BA's `user.modelName`). */
|
|
60
60
|
modelOverrides?: Partial<Record<string, string>>;
|
|
61
|
+
/**
|
|
62
|
+
* Canonical collection names to SKIP — because something else owns their model.
|
|
63
|
+
*
|
|
64
|
+
* The normal reason is `createBetterAuthOverlay`: a host wants stubs for the collections it merely
|
|
65
|
+
* REFERENCES (`organization`, `member`) and a full overlay for the one it exposes CRUD on (`user`).
|
|
66
|
+
* Without this the two helpers collide — the stub registers `user` first, and the overlay then
|
|
67
|
+
* THROWS, correctly, because mongoose locks a schema on first `model()` and its `additionalFields`
|
|
68
|
+
* would be silently dropped.
|
|
69
|
+
*
|
|
70
|
+
* Names are CANONICAL (`'user'`, not a pluralised or overridden model name); exclusion is applied
|
|
71
|
+
* before `usePlural` / `modelOverrides`, so a caller does not have to predict the final name.
|
|
72
|
+
*/
|
|
73
|
+
exclude?: string[];
|
|
61
74
|
}
|
|
62
75
|
/**
|
|
63
76
|
* Register stub Mongoose models for Better Auth's collections so that
|
|
@@ -1,8 +1,45 @@
|
|
|
1
|
-
import { n as Repository } from "../Repository-
|
|
2
|
-
import { n as createMongooseAdapter } from "../adapter-
|
|
1
|
+
import { n as Repository } from "../Repository-BQ3FEnOa.mjs";
|
|
2
|
+
import { n as createMongooseAdapter } from "../adapter-BitHg-CN.mjs";
|
|
3
3
|
import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@classytic/repo-core/better-auth";
|
|
4
4
|
//#region src/better-auth/index.ts
|
|
5
5
|
/**
|
|
6
|
+
* Field key with ORDER PRESERVED — a compound index is identified by its key sequence.
|
|
7
|
+
* `{ organizationId: 1, createdAt: -1 }` is a DIFFERENT index from `{ createdAt: -1, organizationId: 1 }`
|
|
8
|
+
* (they serve different queries), so sorting the keys here would wrongly equate them.
|
|
9
|
+
*/
|
|
10
|
+
function indexFieldsKey(fields) {
|
|
11
|
+
return Object.entries(fields).map(([k, v]) => `${k}:${String(v)}`).join(",");
|
|
12
|
+
}
|
|
13
|
+
/** Deterministic canonical form (sorted object keys, recursive) for value equality. */
|
|
14
|
+
function canonical(value) {
|
|
15
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
16
|
+
if (value && typeof value === "object") {
|
|
17
|
+
const obj = value;
|
|
18
|
+
return Object.keys(obj).sort().reduce((acc, k) => {
|
|
19
|
+
acc[k] = canonical(obj[k]);
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
}
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Is every DECLARED option satisfied by the existing index's options? A subset check, not
|
|
27
|
+
* equality: Mongoose augments stored index options with defaults (e.g. `background`), so the
|
|
28
|
+
* existing side legitimately carries extra keys. We require each declared key to deep-equal the
|
|
29
|
+
* existing value — covering ALL declared options (unique, sparse, expireAfterSeconds, collation,
|
|
30
|
+
* name, weights, default_language, partialFilterExpression, …) with no hand-maintained subset.
|
|
31
|
+
*/
|
|
32
|
+
function declaredOptionsSatisfied(declared = {}, existing = {}) {
|
|
33
|
+
for (const [key, value] of Object.entries(declared)) if (JSON.stringify(canonical(value)) !== JSON.stringify(canonical(existing[key]))) return false;
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/** Which declared indexes are NOT already present on the existing model's schema. */
|
|
37
|
+
function missingIndexesOn(existing, declared) {
|
|
38
|
+
if (declared.length === 0) return [];
|
|
39
|
+
const existingIndexes = (existing?.schema)?.indexes?.() ?? [];
|
|
40
|
+
return declared.filter((d) => !existingIndexes.some(([fields, options]) => indexFieldsKey(fields) === indexFieldsKey(d.fields) && declaredOptionsSatisfied(d.options ?? {}, options ?? {})));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
6
43
|
* Register stub Mongoose models for Better Auth's collections so that
|
|
7
44
|
* Mongoose-based resources can `.populate()` references to BA-owned
|
|
8
45
|
* documents. Idempotent — safe to call multiple times.
|
|
@@ -22,10 +59,14 @@ import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@cl
|
|
|
22
59
|
* already existed on `mongoose.models`).
|
|
23
60
|
*/
|
|
24
61
|
function registerBetterAuthStubs(mongoose, options = {}) {
|
|
25
|
-
const
|
|
62
|
+
const excluded = new Set(options.exclude ?? []);
|
|
63
|
+
const names = resolveBetterAuthCollections({
|
|
64
|
+
...options,
|
|
65
|
+
...excluded.size ? { exclude: [...excluded] } : {}
|
|
66
|
+
});
|
|
26
67
|
const registered = [];
|
|
27
68
|
for (const finalName of names) {
|
|
28
|
-
if (mongoose.models
|
|
69
|
+
if (finalName in mongoose.models) continue;
|
|
29
70
|
const schema = new mongoose.Schema({}, {
|
|
30
71
|
strict: false,
|
|
31
72
|
collection: finalName,
|
|
@@ -59,8 +100,37 @@ async function createBetterAuthOverlay(options) {
|
|
|
59
100
|
const tableConfig = ctx.tables[collection];
|
|
60
101
|
if (!tableConfig) throw new Error(`[mongokit:better-auth] Better Auth has no table named '${collection}'. Available: ${Object.keys(ctx.tables).join(", ")}. Did you enable the right plugin in your betterAuth() config?`);
|
|
61
102
|
const finalName = usePlural ? pluralizeBetterAuthCollection(tableConfig.modelName) : tableConfig.modelName;
|
|
62
|
-
if (mongoose.models
|
|
63
|
-
|
|
103
|
+
if (finalName in mongoose.models) {
|
|
104
|
+
const declared = Object.keys(additionalFields);
|
|
105
|
+
if (declared.length > 0 || indexes.length > 0) {
|
|
106
|
+
/**
|
|
107
|
+
* Distinguish "a STUB got here first" from "this same overlay already ran in this process".
|
|
108
|
+
*
|
|
109
|
+
* The guard exists because mongoose locks a schema on first `model()`, so declared
|
|
110
|
+
* `additionalFields` would be silently dropped. That danger is real when a
|
|
111
|
+
* `registerBetterAuthStubs()` call registered an EMPTY `strict: false` schema first.
|
|
112
|
+
*
|
|
113
|
+
* It is NOT real on a re-boot: a process that composes the app twice (every integration suite,
|
|
114
|
+
* and any host that recomposes) hits an existing model whose schema ALREADY carries these exact
|
|
115
|
+
* paths, because an identical overlay call put them there. Throwing then just makes the second
|
|
116
|
+
* boot impossible — which is precisely why hosts hand-rolled `models.X || model(X, schema)` and
|
|
117
|
+
* inherited the silent-drop bug this guard was written to stop.
|
|
118
|
+
*
|
|
119
|
+
* So the test is the SCHEMA, not the mere presence of a model: if every declared field is
|
|
120
|
+
* already a path, the fields are applied and reuse is safe. If any is missing, something else
|
|
121
|
+
* owns this model and the throw stands.
|
|
122
|
+
*/
|
|
123
|
+
const existing = mongoose.models[finalName];
|
|
124
|
+
const paths = existing?.schema?.paths ?? {};
|
|
125
|
+
const missing = declared.filter((f) => !(f in paths));
|
|
126
|
+
const missingIdx = missingIndexesOn(existing, indexes);
|
|
127
|
+
if (missing.length > 0 || missingIdx.length > 0) {
|
|
128
|
+
const parts = [];
|
|
129
|
+
if (missing.length > 0) parts.push(`${missing.length === 1 ? "field" : "fields"} ${missing.map((f) => `'${f}'`).join(", ")}`);
|
|
130
|
+
if (missingIdx.length > 0) parts.push(`${missingIdx.length === 1 ? "index" : "indexes"} on ${missingIdx.map((i) => `{${Object.keys(i.fields).join(",")}}`).join(", ")}`);
|
|
131
|
+
throw new Error(`[mongokit:better-auth] '${finalName}' already registered on mongoose.models WITHOUT ${parts.join(" and ")}. Cannot apply additionalFields / indexes from this createBetterAuthOverlay() call — mongoose locks schema on first model() call, so they would be SILENTLY DROPPED. Either: (a) exclude '${finalName}' from the prior registerBetterAuthStubs() call (\`exclude: ['${collection}']\`), or (b) move additionalFields / indexes there.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
64
134
|
}
|
|
65
135
|
let Model = mongoose.models[finalName];
|
|
66
136
|
if (!Model) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { n as Repository } from "./Repository-
|
|
2
|
-
import { a as
|
|
1
|
+
import { n as Repository } from "./Repository-BQ3FEnOa.mjs";
|
|
2
|
+
import { a as customIdPlugin, f as auditTrailPlugin, i as multiTenantPlugin, m as auditLogPlugin, n as softDeletePlugin, t as timestampPlugin, u as cachePlugin } from "./timestamp.plugin-i9Qxm6kn.mjs";
|
|
3
|
+
import { n as batchOperationsPlugin, t as methodRegistryPlugin } from "./method-registry.plugin-DblM7V6j.mjs";
|
|
3
4
|
//#region src/create-repository.ts
|
|
4
5
|
function isLoggerAudit(value) {
|
|
5
6
|
const v = value;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { c as PaginationConfig } from "./pagination-jSUdrACK.mjs";
|
|
2
|
+
import { _ as RepositoryOptions, d as PluginType } from "./repository-Q16ErTu8.mjs";
|
|
3
|
+
import { T as AuditTrailOptions, _ as RepositoryCachePluginOptions, i as CustomIdOptions, t as MultiTenantOptions } from "./multi-tenant.plugin-2VtSSm1Y.mjs";
|
|
4
|
+
import { n as Repository } from "./Repository-BAzymuOz.mjs";
|
|
5
|
+
import { i as Logger, o as SoftDeleteOptions } from "./plugin-options-BsFH0sTi.mjs";
|
|
6
|
+
import { Model } from "mongoose";
|
|
7
|
+
//#region src/create-repository.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Audit config — either a `Logger` (routes to `auditLogPlugin`, which
|
|
10
|
+
* writes structured log lines through your logger) or an
|
|
11
|
+
* `AuditTrailOptions` object (routes to `auditTrailPlugin`, which
|
|
12
|
+
* persists a queryable compliance ledger in its own collection).
|
|
13
|
+
*
|
|
14
|
+
* Discrimination: a value carrying any of the `Logger` function members
|
|
15
|
+
* (`info` / `warn` / `error` / `debug`) is treated as a logger; anything
|
|
16
|
+
* else is treated as `AuditTrailOptions` (all of whose members are
|
|
17
|
+
* data-shaped except `metadata` / `onError`, which don't overlap with
|
|
18
|
+
* the logger member names).
|
|
19
|
+
*/
|
|
20
|
+
type AuditConfig = Logger | AuditTrailOptions;
|
|
21
|
+
/**
|
|
22
|
+
* Declarative repository config. Every key is optional; a feature's
|
|
23
|
+
* plugin is installed only when its key is present. The remaining
|
|
24
|
+
* `RepositoryOptions` keys (`idField`, `hooks`, `schema`, `updateSchema`,
|
|
25
|
+
* `events`, `requirePlugins`, ...) pass through to the `Repository`
|
|
26
|
+
* constructor unchanged.
|
|
27
|
+
*/
|
|
28
|
+
interface CreateRepositoryConfig extends RepositoryOptions {
|
|
29
|
+
/** Multi-tenant scoping — forwarded to `multiTenantPlugin`. */
|
|
30
|
+
tenant?: MultiTenantOptions;
|
|
31
|
+
/** Soft-delete — `true` for defaults, or `SoftDeleteOptions`. */
|
|
32
|
+
softDelete?: boolean | SoftDeleteOptions;
|
|
33
|
+
/** createdAt/updatedAt stamping — `timestampPlugin` takes no options. */
|
|
34
|
+
timestamps?: boolean;
|
|
35
|
+
/** Batch ops (`updateMany`/`deleteMany`/`bulkWrite`) via `batchOperationsPlugin`. */
|
|
36
|
+
batch?: boolean;
|
|
37
|
+
/** Read-through cache — forwarded to `cachePlugin`. */
|
|
38
|
+
cache?: RepositoryCachePluginOptions;
|
|
39
|
+
/** Audit — `Logger` → `auditLogPlugin`; `AuditTrailOptions` → `auditTrailPlugin`. */
|
|
40
|
+
audit?: AuditConfig;
|
|
41
|
+
/** Custom ID generation — forwarded to `customIdPlugin`. */
|
|
42
|
+
customId?: CustomIdOptions;
|
|
43
|
+
/** Extra plugins appended AFTER the canonical stack. */
|
|
44
|
+
plugins?: PluginType[];
|
|
45
|
+
/** Pagination engine config (defaultLimit, maxLimit, ...). */
|
|
46
|
+
pagination?: PaginationConfig;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Build a `Repository` from a declarative config. See module JSDoc for
|
|
50
|
+
* ordering guarantees and an example.
|
|
51
|
+
*/
|
|
52
|
+
declare function createRepository<TDoc>(model: Model<TDoc, any, any, any>, config?: CreateRepositoryConfig): Repository<TDoc>;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { CreateRepositoryConfig as n, createRepository as r, AuditConfig as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as GroupResult, d as MinMaxResult, f as OperationOptions, g as UpdateOptions, h as UpdateManyResult, i as CreateOptions, o as DeleteResult, s as FindOneAndUpdateOptions, y as LookupOptions } from "./operations-
|
|
1
|
+
import { c as GroupResult, d as MinMaxResult, f as OperationOptions, g as UpdateOptions, h as UpdateManyResult, i as CreateOptions, o as DeleteResult, s as FindOneAndUpdateOptions, y as LookupOptions } from "./operations-CuzX9m2Z.mjs";
|
|
2
2
|
import { a as PopulateSpec, i as ObjectId, l as SortSpec, o as ReadPreferenceType, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
|
|
3
3
|
import { p as UpdateWithValidationResult } from "./type-utils-CLzRFtIA.mjs";
|
|
4
4
|
import { Model, PipelineStage } from "mongoose";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { _ as WithTransactionOptions, c as GroupResult, d as MinMaxResult, f as OperationOptions, g as UpdateOptions, h as UpdateManyResult, i as CreateOptions, l as LookupPopulateOptions, m as SessionOptions, n as CacheOperationOptions, o as DeleteResult, p as ReadOptions, r as CacheableOptions, s as FindOneAndUpdateOptions, t as AggregateOptions, u as LookupPopulateResult, v as LookupBuilder, y as LookupOptions } from "./operations-
|
|
2
|
-
import { a as PopulateSpec, c as SortDirection, i as ObjectId, l as SortSpec, n as AnyModel, o as ReadPreferenceType, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
|
|
1
|
+
import { _ as WithTransactionOptions, c as GroupResult, d as MinMaxResult, f as OperationOptions, g as UpdateOptions, h as UpdateManyResult, i as CreateOptions, l as LookupPopulateOptions, m as SessionOptions, n as CacheOperationOptions, o as DeleteResult, p as ReadOptions, r as CacheableOptions, s as FindOneAndUpdateOptions, t as AggregateOptions, u as LookupPopulateResult, v as LookupBuilder, y as LookupOptions } from "./operations-CuzX9m2Z.mjs";
|
|
2
|
+
import { a as PopulateSpec, c as SortDirection, i as ObjectId, l as SortSpec$1, n as AnyModel, o as ReadPreferenceType, s as SelectSpec, t as AnyDocument } from "./core-62oo3N1C.mjs";
|
|
3
3
|
import { a as DecodedCursor, c as PaginationConfig, i as CursorPayload, l as ValueType, n as BasePaginationOptions, o as KeysetPaginationOptions, r as CollationOptions, s as OffsetPaginationOptions, t as AggregatePaginationOptions } from "./pagination-jSUdrACK.mjs";
|
|
4
|
-
import { t as index_d_exports } from "./index-
|
|
4
|
+
import { t as index_d_exports } from "./index-Beyr1r4d.mjs";
|
|
5
5
|
import { a as InferRawDoc, c as NonNullableFields, d as Strict, f as UpdatePatch, i as InferDocument, l as PartialBy, n as DeepPartial, o as KeysOfType, p as UpdateWithValidationResult, r as DocField, s as MongoOperatorUpdate, t as CreateInput, u as RequiredBy } from "./type-utils-CLzRFtIA.mjs";
|
|
6
|
-
import { S as RepositoryPluginName, _ as RepositoryOptions, a as HookMode, b as MONGOKIT_PLUGIN_NAMES, c as MinimalRepoView, d as PluginType, f as PrioritizedHook, g as RepositoryOperation, h as RepositoryInstance, i as EventPhase, l as Plugin, m as RepositoryEvent, n as EventHandlers, o as Middleware, p as RepositoryContext, r as EventPayload, s as MiddlewareContext, t as AllPluginMethods, u as PluginFunction, v as UserContext, x as MongoKitPluginName, y as WithPlugins } from "./repository-
|
|
7
|
-
import { A as ensureAuditTrailReady, C as AuditTrailMethods, D as AuditTrailQueryOptions, E as AuditTrailQuery, O as EnsureAuditTrailReadyOptions, S as AuditQueryResult, T as AuditTrailOptions, _ as RepositoryCachePluginOptions, a as DateSequentialIdOptions, b as AuditOperation, c as SequentialIdOptions, d as getNextSequence, f as prefixedId, g as RepositoryCacheHandle, h as CacheOptions, i as CustomIdOptions, k as auditTrailPlugin, l as customIdPlugin, m as CacheAdapter, n as adminBypass, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailMode, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-
|
|
6
|
+
import { S as RepositoryPluginName, _ as RepositoryOptions, a as HookMode, b as MONGOKIT_PLUGIN_NAMES, c as MinimalRepoView, d as PluginType, f as PrioritizedHook, g as RepositoryOperation, h as RepositoryInstance, i as EventPhase, l as Plugin, m as RepositoryEvent, n as EventHandlers, o as Middleware, p as RepositoryContext, r as EventPayload, s as MiddlewareContext, t as AllPluginMethods, u as PluginFunction, v as UserContext, x as MongoKitPluginName, y as WithPlugins } from "./repository-Q16ErTu8.mjs";
|
|
7
|
+
import { A as ensureAuditTrailReady, C as AuditTrailMethods, D as AuditTrailQueryOptions, E as AuditTrailQuery, O as EnsureAuditTrailReadyOptions, S as AuditQueryResult, T as AuditTrailOptions, _ as RepositoryCachePluginOptions, a as DateSequentialIdOptions, b as AuditOperation, c as SequentialIdOptions, d as getNextSequence, f as prefixedId, g as RepositoryCacheHandle, h as CacheOptions, i as CustomIdOptions, k as auditTrailPlugin, l as customIdPlugin, m as CacheAdapter, n as adminBypass, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailMode, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-2VtSSm1Y.mjs";
|
|
8
8
|
import { t as PaginationEngine } from "./PaginationEngine-CBS1XGzp.mjs";
|
|
9
|
-
import { a as
|
|
10
|
-
import { a as SoftDeleteFilterMode, c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, n as CascadeRelation, o as SoftDeleteOptions, r as FieldPreset, s as SoftDeleteRepository, t as CascadeOptions } from "./plugin-options-
|
|
11
|
-
import {
|
|
9
|
+
import { a as AggregationPlan, c as SortOrder, i as AggregationBuilder, l as SortSpec, n as Repository, o as GroupSpec, r as TransitionMachine, s as ProjectionSpec, t as HOOK_PRIORITY, u as VectorSearchOptions } from "./Repository-BAzymuOz.mjs";
|
|
10
|
+
import { a as SoftDeleteFilterMode, c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, n as CascadeRelation, o as SoftDeleteOptions, r as FieldPreset, s as SoftDeleteRepository, t as CascadeOptions } from "./plugin-options-BsFH0sTi.mjs";
|
|
11
|
+
import { n as CreateRepositoryConfig, r as createRepository, t as AuditConfig } from "./create-repository-mEdfH9sz.mjs";
|
|
12
|
+
import { A as IdempotencyStoreMethods, B as auditLogPlugin, C as LeaseMethods, D as ImmutableStatesPluginOptions, E as ImmutableClaimView, F as elasticSearchPlugin, H as appendOnlyPlugin, I as cascadePlugin, L as BatchOperationsMethods, M as idempotencyStorePlugin, N as fieldFilterPlugin, O as immutableStatesPlugin, P as ElasticSearchOptions, R as BulkWriteResult, S as methodRegistryPlugin, T as leasePlugin, U as AggregateHelpersMethods, V as AppendOnlyPluginOptions, W as aggregateHelpersPlugin, _ as OperationMetric, a as requireField, b as mongoOperationsPlugin, c as timestampPlugin, d as createTenantContext, f as SubdocumentMethods, g as ObservabilityOptions, h as softDeletePlugin, i as immutableField, j as IdempotencyStorePluginOptions, k as IdempotencyClaim, l as TenantContext, m as SoftDeleteMethods, n as autoInject, o as uniqueField, p as subdocumentPlugin, r as blockIf, s as validationChainPlugin, t as OperationType, u as TenantStore, v as observabilityPlugin, w as LeasePluginOptions, y as MongoOperationsMethods, z as batchOperationsPlugin } from "./validation-chain.plugin-BSshLJTA.mjs";
|
|
12
13
|
import { n as SchemaPathsLike, t as FieldType$1 } from "./coercion-BjdPX3YF.mjs";
|
|
13
14
|
import { n as SchemaIndexes } from "./indexes-DIjMpYES.mjs";
|
|
14
|
-
import {
|
|
15
|
+
import { S as parseDuplicateKeyError, _ as getMongooseProjection, a as createMemoryCache, b as createError, g as getFieldsForUser, h as filterResponseData, i as buildCrudSchemasFromMongooseSchema, m as createFieldPreset, n as CrudSchemasFramework, o as LoggerConfig, r as buildCrudSchemasFromModel, s as configureLogger, t as toPlain, u as idVariants, v as CreateErrorOptions, x as isDuplicateKeyError, y as ParseDuplicateKeyOptions } from "./to-plain-BuX1RUZV.mjs";
|
|
15
16
|
import { RepoCapabilities } from "@classytic/repo-core/repository";
|
|
16
|
-
import { ClientSession, PipelineStage } from "mongoose";
|
|
17
|
+
import { ClientSession, Connection, Model, PipelineStage, Schema } from "mongoose";
|
|
17
18
|
//#region src/actions/cascade-references.d.ts
|
|
18
19
|
type PurgeMode = 'hard' | 'soft' | 'anonymize';
|
|
19
20
|
/** Raw collection surface — a native MongoDB `Collection` or a Mongoose `Model`. */
|
|
@@ -93,30 +94,270 @@ interface ReferencePurgeResult {
|
|
|
93
94
|
declare function cascadePurgeReferences(options: CascadePurgeReferencesOptions): Promise<ReferencePurgeResult[]>;
|
|
94
95
|
//#endregion
|
|
95
96
|
//#region src/capabilities.d.ts
|
|
96
|
-
|
|
97
|
+
/** Three-valued transaction answer. `'unknown'` is NOT `'no'` and NOT `'yes'`. */
|
|
98
|
+
type TransactionSupport = 'yes' | 'no' | 'unknown';
|
|
99
|
+
/**
|
|
100
|
+
* How a capability descriptor's `transactions` flag was arrived at.
|
|
101
|
+
*
|
|
102
|
+
* - `'declared'` — a static kit descriptor (sqlitekit, prismakit, or
|
|
103
|
+
* {@link MONGOKIT_CAPABILITIES} itself). Absent field ⇒ `'declared'`, so
|
|
104
|
+
* every existing kit stays valid without change.
|
|
105
|
+
* - `'observed'` — read off THIS connection's live deployment topology.
|
|
106
|
+
* - `'unknown'` — could not be determined; `transactions` is reported
|
|
107
|
+
* `false` (fail closed), which is a different fact from an observed `false`.
|
|
108
|
+
*/
|
|
109
|
+
type CapabilityResolution = 'declared' | 'observed' | 'unknown';
|
|
110
|
+
/**
|
|
111
|
+
* Mongokit's capability descriptor: `RepoCapabilities` plus the provenance of
|
|
112
|
+
* the `transactions` flag.
|
|
113
|
+
*
|
|
114
|
+
* Structural extension rather than a repo-core change on purpose — the extra
|
|
115
|
+
* key is optional to every other consumer, and {@link transactionResolutionOf}
|
|
116
|
+
* reads it defensively so a kernel can accept ANY `RepoCapabilities` (including
|
|
117
|
+
* a non-mongo kit's) without a cast.
|
|
118
|
+
*/
|
|
119
|
+
interface MongoRepoCapabilities extends RepoCapabilities {
|
|
120
|
+
readonly transactionsResolution: CapabilityResolution;
|
|
121
|
+
/**
|
|
122
|
+
* `LookupOptions.coerce` — join a STRING reference against an `ObjectId` key.
|
|
123
|
+
*
|
|
124
|
+
* Declared HERE and not on repo-core's portable `RepoCapabilities` on
|
|
125
|
+
* purpose: `coerce` is a mongokit-only `LookupOptions` field with no
|
|
126
|
+
* counterpart on repo-core's `LookupSpec`, so a cross-kit caller cannot
|
|
127
|
+
* express it. A portable capability flag for a non-portable option would be
|
|
128
|
+
* decoration — and it would force a repo-core release plus a peer-floor bump
|
|
129
|
+
* on every kit for a field only one of them can honour.
|
|
130
|
+
*
|
|
131
|
+
* It is worth declaring at all because the unsupported case is INVISIBLE: a
|
|
132
|
+
* `$lookup` comparing `string` to `ObjectId` matches nothing and raises no
|
|
133
|
+
* error, so a host cannot tell "not supported here" from "no matches".
|
|
134
|
+
*/
|
|
135
|
+
readonly lookupCoerce: boolean;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Read the provenance of a capability descriptor's `transactions` flag.
|
|
139
|
+
* A descriptor without the field is a static declaration (`'declared'`) —
|
|
140
|
+
* which is exactly right for sqlitekit / prismakit / any kit whose answer
|
|
141
|
+
* genuinely does not depend on a live deployment.
|
|
142
|
+
*/
|
|
143
|
+
declare function transactionResolutionOf(caps: RepoCapabilities): CapabilityResolution;
|
|
144
|
+
/**
|
|
145
|
+
* What MongoDB supports through mongokit's surface, DECLARED (not observed).
|
|
146
|
+
*
|
|
147
|
+
* Deployment-dependent flags (`transactions`, `nestedTransactions`,
|
|
148
|
+
* `changeStreams` — all three need a replica set or mongos) are `true` here
|
|
149
|
+
* because they describe the product, not the server you happen to be pointed
|
|
150
|
+
* at. **Do not read this constant to decide whether a live connection can run
|
|
151
|
+
* a transaction** — that is {@link resolveMongoCapabilities}, which is what
|
|
152
|
+
* `Repository#capabilities` returns. This one is for the cross-kit conformance
|
|
153
|
+
* harness (which overrides environment-specific limits where it is
|
|
154
|
+
* constructed) and as the base every observed descriptor is derived from.
|
|
155
|
+
*/
|
|
156
|
+
declare const MONGOKIT_CAPABILITIES: MongoRepoCapabilities;
|
|
157
|
+
interface ServerDescriptionLike {
|
|
158
|
+
readonly type?: string | undefined;
|
|
159
|
+
}
|
|
160
|
+
interface TopologyDescriptionLike {
|
|
161
|
+
readonly type?: string | undefined;
|
|
162
|
+
readonly servers?: ReadonlyMap<string, ServerDescriptionLike> | Record<string, ServerDescriptionLike> | undefined;
|
|
163
|
+
}
|
|
164
|
+
interface ClientLike {
|
|
165
|
+
readonly topology?: {
|
|
166
|
+
readonly description?: TopologyDescriptionLike | undefined;
|
|
167
|
+
} | undefined;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The slice of a Mongoose `Connection` this module touches. Structural on
|
|
171
|
+
* purpose — mongokit's topology helpers stay usable with a raw `MongoClient`,
|
|
172
|
+
* a `Connection`, or a test double, and never import mongoose types.
|
|
173
|
+
*/
|
|
174
|
+
interface CapabilityConnectionLike {
|
|
175
|
+
readyState?: number | undefined;
|
|
176
|
+
getClient?: (() => ClientLike | undefined) | undefined;
|
|
177
|
+
client?: ClientLike | undefined;
|
|
178
|
+
asPromise?: (() => Promise<unknown>) | undefined;
|
|
179
|
+
db?: {
|
|
180
|
+
admin?: (() => {
|
|
181
|
+
command: (cmd: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
182
|
+
}) | undefined;
|
|
183
|
+
} | undefined;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Read whether a connection's LIVE deployment supports multi-document
|
|
187
|
+
* transactions, synchronously, from the driver's SDAM topology description.
|
|
188
|
+
*
|
|
189
|
+
* Free (a few property reads against an object the driver keeps current), so
|
|
190
|
+
* it is deliberately NOT memoized — a connection that opens after the repo was
|
|
191
|
+
* constructed upgrades its own answer with no invalidation step. What IS
|
|
192
|
+
* memoized is the async {@link probeMongoCapabilities} result, which this
|
|
193
|
+
* function consults first so an exotic deployment that answered `hello` but
|
|
194
|
+
* exposes no topology still reports definitively.
|
|
195
|
+
*
|
|
196
|
+
* @returns `'yes'` / `'no'` when the topology is conclusive, `'unknown'`
|
|
197
|
+
* otherwise — never optimistic. See the module docblock on rule 3.
|
|
198
|
+
*/
|
|
199
|
+
declare function resolveTransactionSupport(connection: unknown): TransactionSupport;
|
|
200
|
+
/**
|
|
201
|
+
* The capability descriptor for a LIVE connection — what
|
|
202
|
+
* `Repository#capabilities` returns.
|
|
203
|
+
*
|
|
204
|
+
* Every deployment-dependent flag reflects the observed topology; everything
|
|
205
|
+
* else comes from {@link MONGOKIT_CAPABILITIES}. Cheap enough to call per
|
|
206
|
+
* access (topology read + one frozen-object lookup).
|
|
207
|
+
*/
|
|
208
|
+
declare function resolveMongoCapabilities(connection: unknown): MongoRepoCapabilities;
|
|
209
|
+
/** The three derived descriptors, for tests and for gates that want to compare identity. */
|
|
210
|
+
declare function capabilitiesForSupport(support: TransactionSupport): MongoRepoCapabilities;
|
|
211
|
+
/** Test seam — drop memoized probe answers (a reused connection object across suites). */
|
|
212
|
+
declare function resetCapabilityProbeCache(connection?: unknown): void;
|
|
213
|
+
/** Options for {@link probeMongoCapabilities}. */
|
|
214
|
+
interface CapabilityProbeOptions {
|
|
215
|
+
/**
|
|
216
|
+
* Hard ceiling on the whole probe (waiting for the connection to open PLUS
|
|
217
|
+
* the `hello` round-trip). Exceeding it yields `'unknown'` — a bounded
|
|
218
|
+
* wrong-but-loud answer, never a hang at boot. Default 2000ms.
|
|
219
|
+
*/
|
|
220
|
+
timeoutMs?: number;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Classify a `hello` (or legacy `isMaster`) reply.
|
|
224
|
+
*
|
|
225
|
+
* - `msg: 'isdbgrid'` ⇒ mongos ⇒ transactions (Mongo 4.2+ sharded).
|
|
226
|
+
* - `setName` ⇒ a replica-set member ⇒ transactions.
|
|
227
|
+
* - a reply that IS a hello (`isWritablePrimary` / `ismaster` present) with
|
|
228
|
+
* neither marker ⇒ standalone ⇒ **no**. Verified: a memory-server standalone
|
|
229
|
+
* returns `{ isWritablePrimary: true }` and nothing else.
|
|
230
|
+
* - anything unrecognised ⇒ `'unknown'`. A reply we cannot parse is not a yes.
|
|
231
|
+
*/
|
|
232
|
+
declare function classifyHelloReply(reply: Record<string, unknown> | undefined): TransactionSupport;
|
|
233
|
+
/**
|
|
234
|
+
* Resolve a connection's real capabilities, waiting for (and if necessary
|
|
235
|
+
* asking) the deployment. Memoized per connection: N repositories and N
|
|
236
|
+
* kernels on one connection issue at most ONE `hello`.
|
|
237
|
+
*
|
|
238
|
+
* Hosts do not have to call this — `Repository#capabilities` reads the live
|
|
239
|
+
* topology synchronously, which is already conclusive once
|
|
240
|
+
* `await mongoose.connect()` has returned (the Kernel Construction Standard's
|
|
241
|
+
* Describe → **Bind** ordering guarantees that). It exists for the cases the
|
|
242
|
+
* sync read cannot cover: binding while a connection is still opening, or a
|
|
243
|
+
* deployment whose driver surfaces no topology description. Calling it makes
|
|
244
|
+
* the SUBSEQUENT synchronous reads definitive, so nothing else needs rewiring:
|
|
245
|
+
*
|
|
246
|
+
* ```ts
|
|
247
|
+
* await probeMongoCapabilities(connection); // once, before bind
|
|
248
|
+
* const engine = defineWallet().bind(connection); // gate now sees the truth
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* Only definitive answers are cached — an `'unknown'` may be re-probed later
|
|
252
|
+
* (the deployment may simply not have been up yet).
|
|
253
|
+
*/
|
|
254
|
+
declare function probeMongoCapabilities(connection: unknown, options?: CapabilityProbeOptions): Promise<MongoRepoCapabilities>;
|
|
97
255
|
//#endregion
|
|
98
256
|
//#region src/filter/compile.d.ts
|
|
257
|
+
declare function compileFilterToMongo(input: unknown,
|
|
258
|
+
/**
|
|
259
|
+
* Mongoose schema for the collection being filtered. Supply it wherever it is available:
|
|
260
|
+
* without it the date coercion guesses from the value's SHAPE alone and silently breaks
|
|
261
|
+
* range filters on ISO-shaped string columns. See `CoerceFilterDatesOptions.isDateField`.
|
|
262
|
+
*/
|
|
263
|
+
schema?: Schema): Record<string, unknown>;
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/model-blueprint.d.ts
|
|
266
|
+
/**
|
|
267
|
+
* What a bind does when a model name is ALREADY registered on the connection.
|
|
268
|
+
*
|
|
269
|
+
* There is no default — the kernel chooses per model, because the three are not
|
|
270
|
+
* interchangeable and a silent choice is how schema/index contributions get dropped.
|
|
271
|
+
*/
|
|
272
|
+
type ExistingModelPolicy =
|
|
273
|
+
/**
|
|
274
|
+
* The caller is contributing schema (fields, indexes) Mongoose cannot apply to a locked
|
|
275
|
+
* schema — reusing would silently drop it, so fail loud. The production default.
|
|
276
|
+
*/
|
|
277
|
+
{
|
|
278
|
+
readonly mode: 'throw';
|
|
279
|
+
readonly hint?: string;
|
|
280
|
+
} |
|
|
281
|
+
/** Idempotent registration — the caller adds nothing new, so an existing model is correct. */
|
|
282
|
+
{
|
|
283
|
+
readonly mode: 'reuse';
|
|
284
|
+
} |
|
|
285
|
+
/**
|
|
286
|
+
* Clobber an existing model, then register fresh. An explicit test/development escape hatch
|
|
287
|
+
* (hot-reload, fixtures) — replacing a live model in production is a footgun and THROWS.
|
|
288
|
+
* `environment` documents intent; a bind still refuses when `NODE_ENV === 'production'`.
|
|
289
|
+
*/
|
|
290
|
+
{
|
|
291
|
+
readonly mode: 'replace';
|
|
292
|
+
readonly environment: 'test' | 'development';
|
|
293
|
+
};
|
|
294
|
+
interface ModelSpec<TDocument = unknown> {
|
|
295
|
+
readonly name: string;
|
|
296
|
+
/** Explicit collection name. Omit for Mongoose's default pluralization. */
|
|
297
|
+
readonly collection?: string;
|
|
298
|
+
/** Schema FACTORY — built at most once, only when this model is actually registered. */
|
|
299
|
+
readonly schema: () => Schema<TDocument>;
|
|
300
|
+
/** What to do if `name` is already registered on the bind connection. */
|
|
301
|
+
readonly existing: ExistingModelPolicy;
|
|
302
|
+
}
|
|
303
|
+
interface ModelBlueprint<TModels> {
|
|
304
|
+
/** Every model name this blueprint will register — known WITHOUT a connection. */
|
|
305
|
+
readonly modelNames: readonly string[];
|
|
306
|
+
/**
|
|
307
|
+
* Compile + register every model on `connection`, then assemble the typed model bag.
|
|
308
|
+
*
|
|
309
|
+
* Registration is connection-local (uses `connection.models`, never the global registry).
|
|
310
|
+
* On a partial failure, models THIS bind created are removed from the connection's registry
|
|
311
|
+
* (a registry rollback — it never touches database collections) and the original error is
|
|
312
|
+
* re-thrown with the names that had already bound.
|
|
313
|
+
*/
|
|
314
|
+
bind(connection: Connection): TModels;
|
|
315
|
+
}
|
|
99
316
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* Mirrors sqlitekit's `compileFilterToDrizzle`: takes a repo-core
|
|
103
|
-
* `Filter` tree and emits a MongoDB query object. Used by `groupBy` /
|
|
104
|
-
* `groupByPaginate` to translate the portable AggRequest's `filter`
|
|
105
|
-
* + `having` into `$match` stages.
|
|
106
|
-
*
|
|
107
|
-
* Scope: the same operator set sqlitekit supports (`eq`, `ne`, `gt`,
|
|
108
|
-
* `gte`, `lt`, `lte`, `in`, `nin`, `exists`, `like`, `regex`, `and`,
|
|
109
|
-
* `or`, `not`, `raw`). Anything else throws so we fail loud instead
|
|
110
|
-
* of silently dropping predicates.
|
|
111
|
-
*
|
|
112
|
-
* Why only this op set here and not everywhere in mongokit? Historic
|
|
113
|
-
* reason: mongokit pre-dates repo-core's Filter IR, so its existing
|
|
114
|
-
* policy plugins (multi-tenant, soft-delete) speak MongoDB query
|
|
115
|
-
* language directly. Converting mongokit's entire filter pipeline
|
|
116
|
-
* to Filter IR is out-of-scope for this change — we introduce the
|
|
117
|
-
* compiler only where the new portable `groupBy` IR needs it.
|
|
317
|
+
* Describe a set of models as a connection-free blueprint. Duplicate spec names are rejected
|
|
318
|
+
* here, at describe time, before any connection is involved.
|
|
118
319
|
*/
|
|
119
|
-
declare function
|
|
320
|
+
declare function defineModels<TModels>(spec: {
|
|
321
|
+
readonly models: readonly ModelSpec<any>[];
|
|
322
|
+
/** Turn the bound `name -> Model` map into the kernel's typed model bag. */
|
|
323
|
+
readonly assemble: (models: ReadonlyMap<string, Model<unknown>>) => TModels;
|
|
324
|
+
}): ModelBlueprint<TModels>;
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/model-registry.d.ts
|
|
327
|
+
/**
|
|
328
|
+
* A model name was already registered when a `throw` policy required it to be free.
|
|
329
|
+
*
|
|
330
|
+
* Typed (not a bare `Error`) so consumers — kernels wrapping their own domain collision error,
|
|
331
|
+
* tests asserting the failure — can `instanceof`-check it instead of matching a message string.
|
|
332
|
+
*/
|
|
333
|
+
declare class ModelCollisionError extends Error {
|
|
334
|
+
readonly modelName: string;
|
|
335
|
+
constructor(modelName: string, detail?: string);
|
|
336
|
+
}
|
|
337
|
+
interface DefineModelOptions {
|
|
338
|
+
/** What to do when the name is already registered. Required — see the note above. */
|
|
339
|
+
onExisting: 'reuse' | 'throw';
|
|
340
|
+
/** Register on a specific connection instead of the default mongoose instance. */
|
|
341
|
+
connection?: Connection;
|
|
342
|
+
/** Extra context appended to the `throw` message (which call site, what would be lost). */
|
|
343
|
+
throwHint?: string;
|
|
344
|
+
/**
|
|
345
|
+
* Explicit collection name — Mongoose's third `model()` argument. Omit for Mongoose's
|
|
346
|
+
* default pluralization. Passed through only on a FRESH registration (a `reuse` hit
|
|
347
|
+
* returns the existing model, whose collection is already fixed).
|
|
348
|
+
*/
|
|
349
|
+
collection?: string;
|
|
350
|
+
}
|
|
351
|
+
/** Is this model name already registered? Prefer {@link defineModel} over asking. */
|
|
352
|
+
declare function isModelRegistered(name: string, connection?: Connection): boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Register a model, or return the existing one, according to `onExisting`.
|
|
355
|
+
*
|
|
356
|
+
* `schema` is a FACTORY so it is never built when an existing model wins — building a
|
|
357
|
+
* schema has side effects (plugin application, index declaration) that should not run for
|
|
358
|
+
* a registration that is about to be discarded.
|
|
359
|
+
*/
|
|
360
|
+
declare function defineModel<TDoc>(name: string, schema: () => Schema<TDoc>, options: DefineModelOptions): Model<TDoc>;
|
|
120
361
|
//#endregion
|
|
121
362
|
//#region src/operations.d.ts
|
|
122
363
|
/**
|
|
@@ -155,7 +396,7 @@ declare const READ_OPERATIONS: readonly RepositoryOperation[];
|
|
|
155
396
|
declare function operationsByPolicyKey(key: PolicyKey): RepositoryOperation[];
|
|
156
397
|
//#endregion
|
|
157
398
|
//#region src/query/parser/types.d.ts
|
|
158
|
-
type SortSpec$
|
|
399
|
+
type SortSpec$2 = Record<string, 1 | -1>;
|
|
159
400
|
type FilterQuery = Record<string, unknown>;
|
|
160
401
|
/**
|
|
161
402
|
* Mongoose-compatible populate option
|
|
@@ -177,7 +418,7 @@ interface PopulateOption {
|
|
|
177
418
|
/** Query options (limit, sort, skip) */
|
|
178
419
|
options?: {
|
|
179
420
|
limit?: number;
|
|
180
|
-
sort?: SortSpec$
|
|
421
|
+
sort?: SortSpec$2;
|
|
181
422
|
skip?: number;
|
|
182
423
|
};
|
|
183
424
|
/** Nested populate configuration */
|
|
@@ -188,7 +429,7 @@ interface ParsedQuery {
|
|
|
188
429
|
/** MongoDB filter query */
|
|
189
430
|
filters: FilterQuery;
|
|
190
431
|
/** Sort specification */
|
|
191
|
-
sort?: SortSpec$
|
|
432
|
+
sort?: SortSpec$2;
|
|
192
433
|
/** Fields to populate (simple comma-separated string) */
|
|
193
434
|
populate?: string;
|
|
194
435
|
/**
|
|
@@ -359,6 +600,19 @@ declare class QueryParser {
|
|
|
359
600
|
* Returns `undefined` if no whitelist is set (all fields allowed).
|
|
360
601
|
*/
|
|
361
602
|
get allowedSortFields(): string[] | undefined;
|
|
603
|
+
/**
|
|
604
|
+
* The configured page-size cap — EXPOSED so a caller does not apply a second one.
|
|
605
|
+
*
|
|
606
|
+
* A resource that constructs `new QueryParser({ maxLimit: 1000 })` has answered the
|
|
607
|
+
* question "how large may a page be?". Without a way to read it back, every layer
|
|
608
|
+
* downstream applies its own default and the LOWEST silently wins — which is exactly
|
|
609
|
+
* what happened: a resource asked for 1000, a repository was configured for 1000, and
|
|
610
|
+
* arc's `QueryResolver` capped at its own default of 100. Three caps, one winner, no
|
|
611
|
+
* signal, and an account picker that showed 100 of 696 rows.
|
|
612
|
+
*
|
|
613
|
+
* Read this instead of defaulting when a parser is supplied.
|
|
614
|
+
*/
|
|
615
|
+
get maxLimit(): number;
|
|
362
616
|
/**
|
|
363
617
|
* Get the configured allowed operators.
|
|
364
618
|
* Returns `undefined` if no whitelist is set (all built-in operators allowed).
|
|
@@ -495,15 +749,23 @@ declare function isTransactionUnsupported(error: Error): boolean;
|
|
|
495
749
|
/**
|
|
496
750
|
* PROACTIVELY report whether a connection's deployment supports multi-document
|
|
497
751
|
* transactions — the read-side companion to {@link isTransactionUnsupported}
|
|
498
|
-
* (which classifies a FAILED attempt).
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
752
|
+
* (which classifies a FAILED attempt). Lets a caller skip a doomed transaction
|
|
753
|
+
* attempt on standalone dev Mongo rather than starting one just to catch the
|
|
754
|
+
* error.
|
|
755
|
+
*
|
|
756
|
+
* Delegates to {@link resolveTransactionSupport} so mongokit has exactly ONE
|
|
757
|
+
* topology reader. That also fixes a false NEGATIVE this function used to
|
|
758
|
+
* have: it tested `description.type !== 'Single'`, but a single-node replica
|
|
759
|
+
* set reached with `directConnection` is `Single` with a server type of
|
|
760
|
+
* `RSPrimary` and runs transactions fine. The shared reader looks at the
|
|
761
|
+
* SERVER descriptions first.
|
|
762
|
+
*
|
|
763
|
+
* **`unknown` is optimistic HERE and pessimistic in `capabilities.ts` — the
|
|
764
|
+
* difference is deliberate.** This answers "should I bother ATTEMPTING a
|
|
765
|
+
* transaction?", where guessing yes costs one caught error (`allowFallback`
|
|
766
|
+
* still recovers). The capability descriptor answers "may this deployment be
|
|
767
|
+
* trusted with money?", where guessing yes is the bug class this repo keeps
|
|
768
|
+
* hitting (AGENTS.md FAIL LOUD rule 3). Do not "unify" them.
|
|
507
769
|
*
|
|
508
770
|
* Accepts a Mongoose `Connection` (or anything exposing `getClient()`/`client`
|
|
509
771
|
* with a driver `topology`), so it stays decoupled from mongoose types.
|
|
@@ -709,4 +971,4 @@ declare function createOptionsExtractor<TCtx extends Record<string, unknown>>(fi
|
|
|
709
971
|
*/
|
|
710
972
|
declare function systemContext(extra?: SessionOptions): SessionOptions;
|
|
711
973
|
//#endregion
|
|
712
|
-
export { ALL_OPERATIONS, type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, AggregationBuilder, type AllPluginMethods, type AnyDocument, type AnyModel, type AppendOnlyPluginOptions, type AuditConfig, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailMode, type AuditTrailOptions, AuditTrailQuery, type AuditTrailQueryOptions, type BasePaginationOptions, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheOperationOptions, type CacheOptions, type CacheableOptions, type CascadeOptions, type CascadePurgeReferencesOptions, type CascadeRelation, type CollationOptions, type CollectionRWLike, type CreateInput, type CreateOptions, type CreateRepositoryConfig, type CursorPayload, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DeleteResult, type DocField, type ElasticSearchOptions, type EnsureAuditTrailReadyOptions, type EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, HOOK_PRIORITY, type HookMode, type IdGenerator, type IdempotencyClaim, type IdempotencyStoreMethods, type IdempotencyStorePluginOptions, type ImmutableClaimView, type ImmutableStatesPluginOptions, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type LeaseMethods, type LeasePluginOptions, type Logger, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, type MongoKitPluginName, type MongoOperationsMethods, type MongoOperatorUpdate, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OperationDescriptor, type OperationMetric, type OperationOptions, type PaginationConfig, PaginationEngine, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, type PrioritizedHook, type PurgeMode, type PurgeableRepoLike, QueryParser, type QueryParserOptions, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, type ReferencePurgeResult, type ReferenceRelation, Repository, Repository as default, type RepositoryCacheHandle, type RepositoryCachePluginOptions, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RepositoryPluginName, 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 TransitionMachine, type UpdateManyResult, type UpdateOptions, type UpdatePatch, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidatorDefinition, type ValueType, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, cascadePurgeReferences, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, uniqueField, validationChainPlugin, withTransaction };
|
|
974
|
+
export { ALL_OPERATIONS, type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, AggregationBuilder, type AggregationPlan, type SortOrder as AggregationSortOrder, type SortSpec as AggregationSortSpec, type AllPluginMethods, type AnyDocument, type AnyModel, type AppendOnlyPluginOptions, type AuditConfig, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailMode, type AuditTrailOptions, AuditTrailQuery, type AuditTrailQueryOptions, type BasePaginationOptions, type BatchOperationsMethods, type BulkWriteResult, type CacheAdapter, type CacheOperationOptions, type CacheOptions, type CacheableOptions, type CapabilityConnectionLike, type CapabilityProbeOptions, type CapabilityResolution, type CascadeOptions, type CascadePurgeReferencesOptions, type CascadeRelation, type CollationOptions, type CollectionRWLike, type CreateErrorOptions, type CreateInput, type CreateOptions, type CreateRepositoryConfig, type CrudSchemasFramework, type CursorPayload, type CustomIdOptions, type DateSequentialIdOptions, type DecodedCursor, type DeepPartial, type DefineModelOptions, type DeleteResult, type DocField, type ElasticSearchOptions, type EnsureAuditTrailReadyOptions, type EventHandlers, type EventPayload, type EventPhase, type ExistingModelPolicy, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, type GroupSpec, HOOK_PRIORITY, type HookMode, type IdGenerator, type IdempotencyClaim, type IdempotencyStoreMethods, type IdempotencyStorePluginOptions, type ImmutableClaimView, type ImmutableStatesPluginOptions, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type LeaseMethods, type LeasePluginOptions, type Logger, type LoggerConfig, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MONGOKIT_CAPABILITIES, MONGOKIT_PLUGIN_NAMES, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, type ModelBlueprint, ModelCollisionError, type ModelSpec, type MongoKitPluginName, type MongoOperationsMethods, type MongoOperatorUpdate, type MongoRepoCapabilities, type MultiTenantOptions, type NonNullableFields, OP_REGISTRY, type ObjectId, type ObservabilityOptions, type OffsetPaginationOptions, type OperationDescriptor, type OperationMetric, type OperationOptions, type OperationType, type PaginationConfig, PaginationEngine, type ParseDuplicateKeyOptions, type ParsedQuery, type PartialBy, type Plugin, type PluginFunction, type PluginType, type PolicyKey, type PopulateOption, type PopulateSpec, type PrefixedIdOptions, type PrioritizedHook, type ProjectionSpec, type PurgeMode, type PurgeableRepoLike, QueryParser, type QueryParserOptions, type QuerySchema, READ_OPERATIONS, type ReadOptions, type ReadPreferenceType, type ReferencePurgeResult, type ReferenceRelation, Repository, Repository as default, type RepositoryCacheHandle, type RepositoryCachePluginOptions, type RepositoryContext, type RepositoryEvent, type RepositoryInstance, type RepositoryOperation, type RepositoryOptions, type RepositoryPluginName, type RequiredBy, type SchemaLike, type SearchMode, type SelectSpec, type SequentialIdOptions, type SessionOptions, type SessionStarter, type SoftDeleteFilterMode, type SoftDeleteMethods, type SoftDeleteOptions, type SoftDeleteRepository, type SortDirection, type SortSpec$1 as SortSpec, type Strict, type SubdocumentMethods, type TenantContext, type TenantStore, type TransactionSupport, type TransitionMachine, type UpdateManyResult, type UpdateOptions, type UpdatePatch, type UpdateWithValidationResult, type UserContext, type ValidationChainOptions, type ValidatorDefinition, type ValueType, type VectorSearchOptions, type WithPlugins, type WithTransactionOptions, index_d_exports as actions, adminBypass, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, capabilitiesForSupport, cascadePlugin, cascadePurgeReferences, classifyHelloReply, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, defineModel, defineModels, elasticSearchPlugin, ensureAuditTrailReady, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, idempotencyStorePlugin, immutableField, immutableStatesPlugin, isDuplicateKeyError, isModelRegistered, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, probeMongoCapabilities, repoOptionsFromCtx, requireField, resetCapabilityProbeCache, resolveMongoCapabilities, resolveTransactionSupport, sequentialId, softDeletePlugin, subdocumentPlugin, supportsTransactions, systemContext, timestampPlugin, toPlain, transactionResolutionOf, uniqueField, validationChainPlugin, withTransaction };
|