@classytic/mongokit 3.21.0 → 3.22.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.
Files changed (27) hide show
  1. package/dist/{PaginationEngine-DYpOD2wY.d.mts → PaginationEngine-CYRTLW6s.d.mts} +1 -1
  2. package/dist/{Repository-dbbgOGjK.mjs → Repository-Dr1MDAen.mjs} +103 -14
  3. package/dist/actions/index.d.mts +1 -1
  4. package/dist/ai/index.d.mts +1 -1
  5. package/dist/better-auth/index.mjs +1 -1
  6. package/dist/{create-repository-0TkQhcv-.d.mts → create-repository-DXa3nMG6.d.mts} +95 -4
  7. package/dist/{create-repository-CJATiAKX.mjs → create-repository-DwODY4rZ.mjs} +2 -2
  8. package/dist/{index-Cg3SWugF.d.mts → index-CENL7LRb.d.mts} +1 -1
  9. package/dist/index.d.mts +8 -8
  10. package/dist/index.mjs +6 -6
  11. package/dist/{multi-tenant.plugin-CTsWz0XK.d.mts → multi-tenant.plugin-CFzMOuZP.d.mts} +1 -1
  12. package/dist/pagination/PaginationEngine.d.mts +1 -1
  13. package/dist/plugins/index.d.mts +4 -4
  14. package/dist/plugins/index.mjs +3 -3
  15. package/dist/testkit/index.d.mts +1 -1
  16. package/dist/testkit/index.mjs +1 -1
  17. package/dist/{timestamp.plugin-nG9Z1JEk.mjs → timestamp.plugin-Cn6LKUIZ.mjs} +1 -1
  18. package/dist/{mongooseToJsonSchema-D2CyAMIC.d.mts → to-plain-qzKeAC6z.d.mts} +31 -2
  19. package/dist/{memory-cache-DI1jb4dz.mjs → to-plain-vksRrLtc.mjs} +32 -1
  20. package/dist/{types-DNFMofHy.d.mts → types-BnRqAJVa.d.mts} +8 -0
  21. package/dist/usage/index.d.mts +23 -0
  22. package/dist/usage/index.mjs +67 -0
  23. package/dist/utils/index.d.mts +2 -2
  24. package/dist/utils/index.mjs +2 -2
  25. package/dist/{validation-chain.plugin-buy3uvyk.d.mts → validation-chain.plugin-D-EjrYpR.d.mts} +63 -2
  26. package/dist/{validation-chain.plugin-Dn_wZYLA.mjs → validation-chain.plugin-D6qWMH5d.mjs} +221 -2
  27. package/package.json +178 -184
@@ -1,4 +1,4 @@
1
- import { A as KeysetPaginationOptions, U as PaginationConfig, V as OffsetPaginationOptions, i as AnyDocument, n as AggregatePaginationOptions } from "./types-DNFMofHy.mjs";
1
+ import { A as KeysetPaginationOptions, U as PaginationConfig, V as OffsetPaginationOptions, i as AnyDocument, n as AggregatePaginationOptions } from "./types-BnRqAJVa.mjs";
2
2
  import { Model } from "mongoose";
3
3
  import { AggregatePaginationResult, KeysetPaginationResult, OffsetPaginationResult } from "@classytic/repo-core/pagination";
4
4
  //#region src/pagination/PaginationEngine.d.ts
@@ -1743,20 +1743,6 @@ function changeEventTimestamp(change) {
1743
1743
  * OBSERVABILITY=300, DEFAULT=500) and the two refs are reference-equal.
1744
1744
  */
1745
1745
  const HOOK_PRIORITY$1 = HOOK_PRIORITY;
1746
- /**
1747
- * Production-grade repository for MongoDB.
1748
- *
1749
- * Extends `@classytic/repo-core/repository`'s `RepositoryBase` for the
1750
- * driver-agnostic hook + plugin plumbing (context builder, priority-sorted
1751
- * event engine, plugin-order validator) while layering every Mongo-specific
1752
- * concern — populate, aggregate, lookup, keyset + cursor pagination, $near
1753
- * rewriting — on top.
1754
- *
1755
- * Public surface is byte-stable with mongokit 3.9 (the `_hooks` property is
1756
- * preserved as a live read-through getter; all CRUD, event, and plugin method
1757
- * signatures unchanged). 3.10 is an internal re-plumbing release; consumers
1758
- * upgrading from 3.9 need no code changes.
1759
- */
1760
1746
  var Repository = class extends RepositoryBase {
1761
1747
  /**
1762
1748
  * Runtime capability descriptor required by `StandardRepo<TDoc>`
@@ -2998,6 +2984,109 @@ var Repository = class extends RepositoryBase {
2998
2984
  });
2999
2985
  }
3000
2986
  /**
2987
+ * State-machine-backed CAS transition with status history — the
2988
+ * canonical domain-verb shape, promoted from the identical helper
2989
+ * every engine package hand-rolled (projects / manufacturing /
2990
+ * assets `claimTransition`).
2991
+ *
2992
+ * One call does the whole liturgy:
2993
+ *
2994
+ * 1. **Legality pre-flight** — `machine.assertTransition(id, from,
2995
+ * to)` for every source state (sync, throws the DOMAIN's typed
2996
+ * error via the machine's `errorFactory` — mongokit never
2997
+ * invents its own transition-error vocabulary).
2998
+ * 2. **Concurrency CAS** — delegates to {@link claim} (multi-source
2999
+ * `from` arrays compile to `$in`; `where` guards AND-merge;
3000
+ * tenant scope / soft-delete / cache / audit plugins all fire).
3001
+ * 3. **History append** — `$push`es `{ status: to, occurredAt, by?,
3002
+ * note? }` onto the history field (default `statusHistory`),
3003
+ * never read-modify-write on the array. Pass `history: false`
3004
+ * for models without a trail.
3005
+ * 4. **Race-loss diagnosis** — on CAS miss it re-reads the row and
3006
+ * throws the ACCURATE error: the machine's own error built from
3007
+ * the row's CURRENT state when that state makes the move illegal
3008
+ * (hand-rolled versions threw with the stale pre-read state), a
3009
+ * 404-shaped error when the row vanished, or a 409
3010
+ * `TRANSITION_RACE_LOST` when the move is still legal from the
3011
+ * current state (caller may re-read and retry).
3012
+ *
3013
+ * The `machine` parameter is STRUCTURAL (`{ name, assertTransition }`)
3014
+ * — `defineStateMachine()` from `@classytic/primitives/state-machine`
3015
+ * satisfies it without mongokit taking a primitives dependency, and
3016
+ * anything else with the same shape works too.
3017
+ *
3018
+ * @example The common verb tail (replaces ~40 lines of base-repo helper)
3019
+ * ```ts
3020
+ * const updated = await repo.applyTransition(id, WORK_ORDER_MACHINE, {
3021
+ * from: existing.status,
3022
+ * to: 'released',
3023
+ * set: { pendingStock: stamp },
3024
+ * by: ctx.actorId,
3025
+ * }, repoOptionsFromCtx(ctx));
3026
+ * ```
3027
+ *
3028
+ * @example Multi-source cancel via the machine's reverse lookup
3029
+ * ```ts
3030
+ * await repo.applyTransition(id, MACHINE, {
3031
+ * from: MACHINE.validSources('cancelled'),
3032
+ * to: 'cancelled',
3033
+ * note: reason,
3034
+ * }, opts);
3035
+ * ```
3036
+ */
3037
+ async applyTransition(id, machine, args, options = {}) {
3038
+ const entityId = String(id);
3039
+ const sources = Array.isArray(args.from) ? args.from : [args.from];
3040
+ for (const from of sources) {
3041
+ if (from === args.to) continue;
3042
+ machine.assertTransition(entityId, from, args.to);
3043
+ }
3044
+ const historyField = args.history === false ? null : args.history ?? "statusHistory";
3045
+ const pushSpec = { ...args.push ?? {} };
3046
+ if (historyField !== null) pushSpec[historyField] = {
3047
+ status: args.to,
3048
+ occurredAt: args.at ?? /* @__PURE__ */ new Date(),
3049
+ ...args.by !== void 0 ? { by: args.by } : {},
3050
+ ...args.note !== void 0 ? { note: args.note } : {}
3051
+ };
3052
+ const patch = {
3053
+ ...args.set !== void 0 && Object.keys(args.set).length > 0 ? { $set: args.set } : {},
3054
+ ...Object.keys(pushSpec).length > 0 ? { $push: pushSpec } : {},
3055
+ ...args.inc !== void 0 && Object.keys(args.inc).length > 0 ? { $inc: args.inc } : {},
3056
+ ...args.unset !== void 0 && Object.keys(args.unset).length > 0 ? { $unset: args.unset } : {}
3057
+ };
3058
+ const updated = await this.claim(id, {
3059
+ from: Array.isArray(args.from) ? args.from : args.from,
3060
+ to: args.to,
3061
+ ...args.field !== void 0 ? { field: args.field } : {},
3062
+ ...args.where !== void 0 ? { where: args.where } : {}
3063
+ }, patch, options);
3064
+ if (updated) return updated;
3065
+ const current = await this.getById(id, {
3066
+ ...options,
3067
+ throwOnNotFound: false
3068
+ });
3069
+ if (!current) throw createError(404, `${machine.name} '${entityId}' not found`, {
3070
+ code: "TRANSITION_TARGET_MISSING",
3071
+ meta: {
3072
+ entityType: machine.name,
3073
+ entityId,
3074
+ to: args.to
3075
+ }
3076
+ });
3077
+ const currentState = (args.field ?? "status").split(".").reduce((acc, key) => acc?.[key], current);
3078
+ if (String(currentState) !== args.to) machine.assertTransition(entityId, String(currentState), args.to);
3079
+ throw createError(409, `${machine.name} '${entityId}' lost the transition race to '${args.to}' (currently '${String(currentState)}'); re-read and retry`, {
3080
+ code: "TRANSITION_RACE_LOST",
3081
+ meta: {
3082
+ entityType: machine.name,
3083
+ entityId,
3084
+ from: String(currentState),
3085
+ to: args.to
3086
+ }
3087
+ });
3088
+ }
3089
+ /**
3001
3090
  * Optimistic-concurrency CAS via a version stamp.
3002
3091
  *
3003
3092
  * Sibling to `claim()` — distinct mental model:
@@ -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-Cg3SWugF.mjs";
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-CENL7LRb.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 };
@@ -1,4 +1,4 @@
1
- import { G as Plugin } from "../types-DNFMofHy.mjs";
1
+ import { G as Plugin } from "../types-BnRqAJVa.mjs";
2
2
  import { PipelineStage } from "mongoose";
3
3
  //#region src/ai/types.d.ts
4
4
  /** Supported similarity metrics for vector search */
@@ -1,4 +1,4 @@
1
- import { n as Repository } from "../Repository-dbbgOGjK.mjs";
1
+ import { n as Repository } from "../Repository-Dr1MDAen.mjs";
2
2
  import { n as createMongooseAdapter } from "../adapter-rTPLUrAV.mjs";
3
3
  import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@classytic/repo-core/better-auth";
4
4
  //#region src/better-auth/index.ts
@@ -1,6 +1,6 @@
1
- import { B as ObjectId, Dt as LookupOptions, Et as LookupBuilder, H as OperationOptions, J as PopulateSpec, M as LookupPopulateOptions, N as LookupPopulateResult, P as Middleware, Q as RepositoryContext, U as PaginationConfig, X as ReadOptions, Y as PrioritizedHook, Z as ReadPreferenceType, _ as DeleteManyResult, at as SessionOptions, c as CacheableOptions, d as CollationOptions, ft as UpdateManyResult, it as SelectSpec, j as Logger, n as AggregatePaginationOptions, nt as RepositoryOptions, p as CreateOptions, pt as UpdateOptions, q as PluginType, st as SoftDeleteOptions, t as AggregateOptions, ut as SortSpec$1, v as DeleteResult, w as FindOneAndUpdateOptions, xt as WithTransactionOptions } from "./types-DNFMofHy.mjs";
2
- import { _ as RepositoryCachePluginOptions, i as CustomIdOptions, t as MultiTenantOptions, w as AuditTrailOptions } from "./multi-tenant.plugin-CTsWz0XK.mjs";
3
- import { t as PaginationEngine } from "./PaginationEngine-DYpOD2wY.mjs";
1
+ import { B as ObjectId, Dt as LookupOptions, Et as LookupBuilder, H as OperationOptions, J as PopulateSpec, M as LookupPopulateOptions, N as LookupPopulateResult, P as Middleware, Q as RepositoryContext, U as PaginationConfig, X as ReadOptions, Y as PrioritizedHook, Z as ReadPreferenceType, _ as DeleteManyResult, at as SessionOptions, c as CacheableOptions, d as CollationOptions, ft as UpdateManyResult, it as SelectSpec, j as Logger, n as AggregatePaginationOptions, nt as RepositoryOptions, p as CreateOptions, pt as UpdateOptions, q as PluginType, st as SoftDeleteOptions, t as AggregateOptions, ut as SortSpec$1, v as DeleteResult, w as FindOneAndUpdateOptions, xt as WithTransactionOptions } from "./types-BnRqAJVa.mjs";
2
+ import { _ as RepositoryCachePluginOptions, i as CustomIdOptions, t as MultiTenantOptions, w as AuditTrailOptions } from "./multi-tenant.plugin-CFzMOuZP.mjs";
3
+ import { t as PaginationEngine } from "./PaginationEngine-CYRTLW6s.mjs";
4
4
  import { AggPaginationRequest, AggRequest, AggResult, ArchiveOptions, ArchiveResult, ArchiveSink, ChangeEvent, FilterInput, KeysetAggPaginationResult, QueryOptions, RepoCapabilities, RepositoryBase, TenantPurgeOptions, TenantPurgeResult, TenantPurgeStrategy, WatchOptions } from "@classytic/repo-core/repository";
5
5
  import { ClientSession, Expression, Model, PipelineStage, PopulateOptions } from "mongoose";
6
6
  import { Filter } from "@classytic/repo-core/filter";
@@ -504,6 +504,19 @@ declare const HOOK_PRIORITY: {
504
504
  * signatures unchanged). 3.10 is an internal re-plumbing release; consumers
505
505
  * upgrading from 3.9 need no code changes.
506
506
  */
507
+ /**
508
+ * Structural contract {@link Repository.applyTransition} requires of a state
509
+ * machine. `defineStateMachine()` from
510
+ * `@classytic/primitives/state-machine` satisfies it as-is — mongokit
511
+ * deliberately does NOT import primitives; compatibility is structural,
512
+ * the same policy as the arc event-shape mirror. `assertTransition`
513
+ * MUST throw (the domain's typed error) on an illegal `from → to`.
514
+ */
515
+ interface TransitionMachine {
516
+ /** Aggregate name — surfaces in race/missing error messages. */
517
+ readonly name: string;
518
+ assertTransition(entityId: string, from: string, to: string): void;
519
+ }
507
520
  declare class Repository<TDoc = unknown> extends RepositoryBase {
508
521
  /**
509
522
  * Runtime capability descriptor required by `StandardRepo<TDoc>`
@@ -1200,6 +1213,84 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
1200
1213
  idField?: string;
1201
1214
  upsert?: boolean;
1202
1215
  }): Promise<TDoc | null>;
1216
+ /**
1217
+ * State-machine-backed CAS transition with status history — the
1218
+ * canonical domain-verb shape, promoted from the identical helper
1219
+ * every engine package hand-rolled (projects / manufacturing /
1220
+ * assets `claimTransition`).
1221
+ *
1222
+ * One call does the whole liturgy:
1223
+ *
1224
+ * 1. **Legality pre-flight** — `machine.assertTransition(id, from,
1225
+ * to)` for every source state (sync, throws the DOMAIN's typed
1226
+ * error via the machine's `errorFactory` — mongokit never
1227
+ * invents its own transition-error vocabulary).
1228
+ * 2. **Concurrency CAS** — delegates to {@link claim} (multi-source
1229
+ * `from` arrays compile to `$in`; `where` guards AND-merge;
1230
+ * tenant scope / soft-delete / cache / audit plugins all fire).
1231
+ * 3. **History append** — `$push`es `{ status: to, occurredAt, by?,
1232
+ * note? }` onto the history field (default `statusHistory`),
1233
+ * never read-modify-write on the array. Pass `history: false`
1234
+ * for models without a trail.
1235
+ * 4. **Race-loss diagnosis** — on CAS miss it re-reads the row and
1236
+ * throws the ACCURATE error: the machine's own error built from
1237
+ * the row's CURRENT state when that state makes the move illegal
1238
+ * (hand-rolled versions threw with the stale pre-read state), a
1239
+ * 404-shaped error when the row vanished, or a 409
1240
+ * `TRANSITION_RACE_LOST` when the move is still legal from the
1241
+ * current state (caller may re-read and retry).
1242
+ *
1243
+ * The `machine` parameter is STRUCTURAL (`{ name, assertTransition }`)
1244
+ * — `defineStateMachine()` from `@classytic/primitives/state-machine`
1245
+ * satisfies it without mongokit taking a primitives dependency, and
1246
+ * anything else with the same shape works too.
1247
+ *
1248
+ * @example The common verb tail (replaces ~40 lines of base-repo helper)
1249
+ * ```ts
1250
+ * const updated = await repo.applyTransition(id, WORK_ORDER_MACHINE, {
1251
+ * from: existing.status,
1252
+ * to: 'released',
1253
+ * set: { pendingStock: stamp },
1254
+ * by: ctx.actorId,
1255
+ * }, repoOptionsFromCtx(ctx));
1256
+ * ```
1257
+ *
1258
+ * @example Multi-source cancel via the machine's reverse lookup
1259
+ * ```ts
1260
+ * await repo.applyTransition(id, MACHINE, {
1261
+ * from: MACHINE.validSources('cancelled'),
1262
+ * to: 'cancelled',
1263
+ * note: reason,
1264
+ * }, opts);
1265
+ * ```
1266
+ */
1267
+ applyTransition(id: string | ObjectId, machine: TransitionMachine, args: {
1268
+ from: string | readonly string[];
1269
+ to: string;
1270
+ /** State field (dotted paths supported) — default `'status'`. */
1271
+ field?: string;
1272
+ /** `$set` payload applied alongside the state write. */
1273
+ set?: Record<string, unknown>;
1274
+ /** Extra `$push` entries merged beside the history append. */
1275
+ push?: Record<string, unknown>;
1276
+ /** `$inc` counters applied alongside the state write. */
1277
+ inc?: Record<string, number>;
1278
+ /** `$unset` paths cleared alongside the state write. */
1279
+ unset?: Record<string, unknown>;
1280
+ /** Additional CAS guards, AND-merged into the filter. */
1281
+ where?: Record<string, unknown>;
1282
+ by?: string;
1283
+ note?: string;
1284
+ /**
1285
+ * History field name (default `'statusHistory'`), or `false` to
1286
+ * skip the append entirely.
1287
+ */
1288
+ history?: string | false;
1289
+ /** Timestamp for the history entry — default `new Date()`. */
1290
+ at?: Date;
1291
+ }, options?: SessionOptions & {
1292
+ idField?: string;
1293
+ }): Promise<TDoc>;
1203
1294
  /**
1204
1295
  * Optimistic-concurrency CAS via a version stamp.
1205
1296
  *
@@ -1754,4 +1845,4 @@ interface CreateRepositoryConfig extends RepositoryOptions {
1754
1845
  */
1755
1846
  declare function createRepository<TDoc>(model: Model<TDoc, any, any, any>, config?: CreateRepositoryConfig): Repository<TDoc>;
1756
1847
  //#endregion
1757
- export { Repository as a, HOOK_PRIORITY as i, CreateRepositoryConfig as n, AggregationBuilder as o, createRepository as r, AuditConfig as t };
1848
+ export { Repository as a, HOOK_PRIORITY as i, CreateRepositoryConfig as n, TransitionMachine as o, createRepository as r, AggregationBuilder as s, AuditConfig as t };
@@ -1,5 +1,5 @@
1
- import { n as Repository } from "./Repository-dbbgOGjK.mjs";
2
- import { a as methodRegistryPlugin, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, t as timestampPlugin } from "./timestamp.plugin-nG9Z1JEk.mjs";
1
+ import { n as Repository } from "./Repository-Dr1MDAen.mjs";
2
+ import { a as methodRegistryPlugin, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, t as timestampPlugin } from "./timestamp.plugin-Cn6LKUIZ.mjs";
3
3
  //#region src/create-repository.ts
4
4
  function isLoggerAudit(value) {
5
5
  const v = value;
@@ -1,4 +1,4 @@
1
- import { B as ObjectId, Dt as LookupOptions, H as OperationOptions, I as MinMaxResult, J as PopulateSpec, T as GroupResult, Z as ReadPreferenceType, ft as UpdateManyResult, ht as UpdateWithValidationResult, i as AnyDocument, it as SelectSpec, p as CreateOptions, pt as UpdateOptions, ut as SortSpec, v as DeleteResult, w as FindOneAndUpdateOptions } from "./types-DNFMofHy.mjs";
1
+ import { B as ObjectId, Dt as LookupOptions, H as OperationOptions, I as MinMaxResult, J as PopulateSpec, T as GroupResult, Z as ReadPreferenceType, ft as UpdateManyResult, ht as UpdateWithValidationResult, i as AnyDocument, it as SelectSpec, p as CreateOptions, pt as UpdateOptions, ut as SortSpec, v as DeleteResult, w as FindOneAndUpdateOptions } from "./types-BnRqAJVa.mjs";
2
2
  import { Model, PipelineStage } from "mongoose";
3
3
  declare namespace aggregate_d_exports {
4
4
  export { aggregate, aggregatePaginate, average, countBy, distinct, facet, groupBy, lookup, minMax, sum, unwind };
package/dist/index.d.mts CHANGED
@@ -1,12 +1,12 @@
1
- import { $ as RepositoryEvent, A as KeysetPaginationOptions, B as ObjectId, C as FieldPreset, Ct as IControllerResponse, D as InferDocument, Dt as LookupOptions, E as HookMode, Et as LookupBuilder, F as MiddlewareContext, G as Plugin, H as OperationOptions, I as MinMaxResult, J as PopulateSpec, K as PluginFunction, L as MinimalRepoView, M as LookupPopulateOptions, N as LookupPopulateResult, O as InferRawDoc, P as Middleware, Q as RepositoryContext, R as MongoOperatorUpdate, S as EventPhase, St as IController, T as GroupResult, Tt as IResponseFormatter, U as PaginationConfig, V as OffsetPaginationOptions, W as PartialBy, X as ReadOptions, Y as PrioritizedHook, Z as ReadPreferenceType, _t as ValidationChainOptions, a as AnyModel, at as SessionOptions, b as EventHandlers, bt as WithPlugins, c as CacheableOptions, ct as SoftDeleteRepository, d as CollationOptions, dt as Strict, et as RepositoryInstance, f as CreateInput, ft as UpdateManyResult, g as DeepPartial, gt as UserContext, h as DecodedCursor, ht as UpdateWithValidationResult, i as AnyDocument, it as SelectSpec, j as Logger, k as KeysOfType, l as CascadeOptions, lt as SortDirection, m as CursorPayload, mt as UpdatePatch, n as AggregatePaginationOptions, nt as RepositoryOptions, o as BasePaginationOptions, ot as SoftDeleteFilterMode, p as CreateOptions, pt as UpdateOptions, q as PluginType, r as AllPluginMethods, rt as RequiredBy, s as CacheOperationOptions, st as SoftDeleteOptions, t as AggregateOptions, tt as RepositoryOperation, u as CascadeRelation, ut as SortSpec, v as DeleteResult, vt as ValidatorDefinition, w as FindOneAndUpdateOptions, wt as IRequestContext, x as EventPayload, xt as WithTransactionOptions, y as DocField, yt as ValueType, z as NonNullableFields } from "./types-DNFMofHy.mjs";
2
- import { t as index_d_exports } from "./index-Cg3SWugF.mjs";
3
- import { C as AuditTrailMethods, E as auditTrailPlugin, S as AuditQueryResult, T as AuditTrailQuery, _ 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, 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 AuditTrailOptions, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-CTsWz0XK.mjs";
4
- import { t as PaginationEngine } from "./PaginationEngine-DYpOD2wY.mjs";
5
- import { a as Repository, i as HOOK_PRIORITY, n as CreateRepositoryConfig, o as AggregationBuilder, r as createRepository, t as AuditConfig } from "./create-repository-0TkQhcv-.mjs";
6
- import { A as BulkWriteResult, C as LeasePluginOptions, D as elasticSearchPlugin, E as ElasticSearchOptions, M as auditLogPlugin, N as AggregateHelpersMethods, O as cascadePlugin, P as aggregateHelpersPlugin, S as LeaseMethods, T as fieldFilterPlugin, _ as observabilityPlugin, a as uniqueField, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as batchOperationsPlugin, k as BatchOperationsMethods, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MongoOperationsMethods, w as leasePlugin, x as methodRegistryPlugin, y as mongoOperationsPlugin } from "./validation-chain.plugin-buy3uvyk.mjs";
1
+ import { $ as RepositoryEvent, A as KeysetPaginationOptions, B as ObjectId, C as FieldPreset, Ct as IControllerResponse, D as InferDocument, Dt as LookupOptions, E as HookMode, Et as LookupBuilder, F as MiddlewareContext, G as Plugin, H as OperationOptions, I as MinMaxResult, J as PopulateSpec, K as PluginFunction, L as MinimalRepoView, M as LookupPopulateOptions, N as LookupPopulateResult, O as InferRawDoc, P as Middleware, Q as RepositoryContext, R as MongoOperatorUpdate, S as EventPhase, St as IController, T as GroupResult, Tt as IResponseFormatter, U as PaginationConfig, V as OffsetPaginationOptions, W as PartialBy, X as ReadOptions, Y as PrioritizedHook, Z as ReadPreferenceType, _t as ValidationChainOptions, a as AnyModel, at as SessionOptions, b as EventHandlers, bt as WithPlugins, c as CacheableOptions, ct as SoftDeleteRepository, d as CollationOptions, dt as Strict, et as RepositoryInstance, f as CreateInput, ft as UpdateManyResult, g as DeepPartial, gt as UserContext, h as DecodedCursor, ht as UpdateWithValidationResult, i as AnyDocument, it as SelectSpec, j as Logger, k as KeysOfType, l as CascadeOptions, lt as SortDirection, m as CursorPayload, mt as UpdatePatch, n as AggregatePaginationOptions, nt as RepositoryOptions, o as BasePaginationOptions, ot as SoftDeleteFilterMode, p as CreateOptions, pt as UpdateOptions, q as PluginType, r as AllPluginMethods, rt as RequiredBy, s as CacheOperationOptions, st as SoftDeleteOptions, t as AggregateOptions, tt as RepositoryOperation, u as CascadeRelation, ut as SortSpec, v as DeleteResult, vt as ValidatorDefinition, w as FindOneAndUpdateOptions, wt as IRequestContext, x as EventPayload, xt as WithTransactionOptions, y as DocField, yt as ValueType, z as NonNullableFields } from "./types-BnRqAJVa.mjs";
2
+ import { t as index_d_exports } from "./index-CENL7LRb.mjs";
3
+ import { C as AuditTrailMethods, E as auditTrailPlugin, S as AuditQueryResult, T as AuditTrailQuery, _ 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, 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 AuditTrailOptions, x as AuditQueryOptions, y as AuditEntry } from "./multi-tenant.plugin-CFzMOuZP.mjs";
4
+ import { t as PaginationEngine } from "./PaginationEngine-CYRTLW6s.mjs";
5
+ import { a as Repository, i as HOOK_PRIORITY, n as CreateRepositoryConfig, o as TransitionMachine, r as createRepository, s as AggregationBuilder, t as AuditConfig } from "./create-repository-DXa3nMG6.mjs";
6
+ import { A as elasticSearchPlugin, C as LeasePluginOptions, D as immutableStatesPlugin, E as ImmutableStatesPluginOptions, F as auditLogPlugin, I as AppendOnlyPluginOptions, L as appendOnlyPlugin, M as BatchOperationsMethods, N as BulkWriteResult, O as fieldFilterPlugin, P as batchOperationsPlugin, R as AggregateHelpersMethods, S as LeaseMethods, T as ImmutableClaimView, _ as observabilityPlugin, a as uniqueField, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as cascadePlugin, k as ElasticSearchOptions, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MongoOperationsMethods, w as leasePlugin, x as methodRegistryPlugin, y as mongoOperationsPlugin, z as aggregateHelpersPlugin } from "./validation-chain.plugin-D-EjrYpR.mjs";
7
7
  import { n as SchemaPathsLike, t as FieldType$1 } from "./coercion-BjdPX3YF.mjs";
8
8
  import { n as SchemaIndexes } from "./indexes-DIjMpYES.mjs";
9
- import { d as filterResponseData, f as getFieldsForUser, g as parseDuplicateKeyError, h as isDuplicateKeyError, i as configureLogger, m as createError, n as buildCrudSchemasFromMongooseSchema, p as getMongooseProjection, r as createMemoryCache, s as idVariants, t as buildCrudSchemasFromModel, u as createFieldPreset } from "./mongooseToJsonSchema-D2CyAMIC.mjs";
9
+ import { _ as parseDuplicateKeyError, a as configureLogger, c as idVariants, d as createFieldPreset, f as filterResponseData, g as isDuplicateKeyError, h as createError, i as createMemoryCache, m as getMongooseProjection, n as buildCrudSchemasFromModel, p as getFieldsForUser, r as buildCrudSchemasFromMongooseSchema, t as toPlain } from "./to-plain-qzKeAC6z.mjs";
10
10
  import { RepoCapabilities } from "@classytic/repo-core/repository";
11
11
  import { ClientSession, PipelineStage } from "mongoose";
12
12
  //#region src/actions/cascade-references.d.ts
@@ -852,4 +852,4 @@ declare function createOptionsExtractor<TCtx extends Record<string, unknown>>(fi
852
852
  */
853
853
  declare function systemContext(extra?: SessionOptions): SessionOptions;
854
854
  //#endregion
855
- export { ALL_OPERATIONS, type AggregateHelpersMethods, type AggregateOptions, type AggregatePaginationOptions, AggregationBuilder, type AllPluginMethods, type AnyDocument, type AnyModel, type AuditConfig, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, 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 EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, HOOK_PRIORITY, type HookMode, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, type InferDocument, type InferRawDoc, type KeysOfType, type KeysetPaginationOptions, type LeaseMethods, type LeasePluginOptions, type Logger, LookupBuilder, type LookupOptions, type LookupPopulateOptions, type LookupPopulateResult, MONGOKIT_CAPABILITIES, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, 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 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 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, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, batchTransaction, blockIf, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, cachePlugin, cascadePlugin, cascadePurgeReferences, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, immutableField, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, systemContext, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
855
+ 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 AuditTrailOptions, AuditTrailQuery, 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 EventHandlers, type EventPayload, type EventPhase, type FieldPreset, type FieldType, type FilterQuery, type FindOneAndUpdateOptions, type GroupResult, HOOK_PRIORITY, type HookMode, type IController, type IControllerResponse, type IRequestContext, type IResponseFormatter, type IdGenerator, 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, MUTATING_OPERATIONS, type Middleware, type MiddlewareContext, type MinMaxResult, type MinimalRepoView, 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 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, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, immutableField, immutableStatesPlugin, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, systemContext, timestampPlugin, toPlain, uniqueField, validationChainPlugin, withTransaction };
package/dist/index.mjs CHANGED
@@ -1,18 +1,18 @@
1
1
  import { n as idVariants } from "./id-resolution-P2OzcyRl.mjs";
2
- import { a as withTransaction, c as MUTATING_OPERATIONS, d as operationsByPolicyKey, f as MONGOKIT_CAPABILITIES, i as isTransactionUnsupported, l as OP_REGISTRY, n as Repository, o as AggregationBuilder, p as createMongoPurgePort, r as batchTransaction, s as ALL_OPERATIONS, t as HOOK_PRIORITY, u as READ_OPERATIONS } from "./Repository-dbbgOGjK.mjs";
2
+ import { a as withTransaction, c as MUTATING_OPERATIONS, d as operationsByPolicyKey, f as MONGOKIT_CAPABILITIES, i as isTransactionUnsupported, l as OP_REGISTRY, n as Repository, o as AggregationBuilder, p as createMongoPurgePort, r as batchTransaction, s as ALL_OPERATIONS, t as HOOK_PRIORITY, u as READ_OPERATIONS } from "./Repository-Dr1MDAen.mjs";
3
3
  import { b as LookupBuilder, x as compileFilterToMongo } from "./update-1Lq9OMD2.mjs";
4
4
  import { n as warn, t as configureLogger } from "./logger-K7dPmu2U.mjs";
5
5
  import { n as isDuplicateKeyError, r as parseDuplicateKeyError, t as createError } from "./error-BuByZwKU.mjs";
6
6
  import { t as actions_exports } from "./actions/index.mjs";
7
- import { a as methodRegistryPlugin, c as getNextSequence, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, l as prefixedId, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, p as AuditTrailQuery, r as adminBypass, s as dateSequentialId, t as timestampPlugin, u as sequentialId } from "./timestamp.plugin-nG9Z1JEk.mjs";
7
+ import { a as methodRegistryPlugin, c as getNextSequence, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, l as prefixedId, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, p as AuditTrailQuery, r as adminBypass, s as dateSequentialId, t as timestampPlugin, u as sequentialId } from "./timestamp.plugin-Cn6LKUIZ.mjs";
8
8
  import { t as PaginationEngine } from "./PaginationEngine-BT1ywu9k.mjs";
9
9
  import { isGeoOperator, parseGeoFilter } from "./query/primitives/geo.mjs";
10
- import { t as createRepository } from "./create-repository-CJATiAKX.mjs";
11
- import { a as uniqueField, c as subdocumentPlugin, d as leasePlugin, f as fieldFilterPlugin, h as aggregateHelpersPlugin, i as requireField, l as observabilityPlugin, m as cascadePlugin, n as blockIf, o as validationChainPlugin, p as elasticSearchPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as mongoOperationsPlugin } from "./validation-chain.plugin-Dn_wZYLA.mjs";
10
+ import { t as createRepository } from "./create-repository-DwODY4rZ.mjs";
11
+ import { _ as aggregateHelpersPlugin, a as uniqueField, c as subdocumentPlugin, d as leasePlugin, f as immutableStatesPlugin, g as appendOnlyPlugin, h as cascadePlugin, i as requireField, l as observabilityPlugin, m as elasticSearchPlugin, n as blockIf, o as validationChainPlugin, p as fieldFilterPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as mongoOperationsPlugin } from "./validation-chain.plugin-D6qWMH5d.mjs";
12
12
  import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-FSQFLpsU.mjs";
13
13
  import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
14
14
  import { extractSchemaIndexes } from "./query/primitives/indexes.mjs";
15
- import { t as createMemoryCache } from "./memory-cache-DI1jb4dz.mjs";
15
+ import { n as createMemoryCache, t as toPlain } from "./to-plain-vksRrLtc.mjs";
16
16
  import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "./mongooseToJsonSchema-CVnrKFDq.mjs";
17
17
  import { runChunkedPurge } from "@classytic/repo-core/repository";
18
18
  import { isControlParam } from "@classytic/repo-core/query-parser";
@@ -1462,4 +1462,4 @@ function systemContext(extra) {
1462
1462
  */
1463
1463
  var src_default = Repository;
1464
1464
  //#endregion
1465
- export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MONGOKIT_CAPABILITIES, 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, cascadePurgeReferences, compileFilterToMongo, configureLogger, createError, createFieldPreset, createMemoryCache, createOptionsExtractor, createRepository, createTenantContext, customIdPlugin, dateSequentialId, src_default as default, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, immutableField, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, systemContext, timestampPlugin, uniqueField, validationChainPlugin, withTransaction };
1465
+ export { ALL_OPERATIONS, AggregationBuilder, AuditTrailQuery, HOOK_PRIORITY, LookupBuilder, MONGOKIT_CAPABILITIES, MUTATING_OPERATIONS, OP_REGISTRY, PaginationEngine, QueryParser, READ_OPERATIONS, Repository, actions_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, src_default as default, elasticSearchPlugin, fieldFilterPlugin, filterResponseData, getFieldsForUser, getMongooseProjection, getNextSequence, idVariants, immutableField, immutableStatesPlugin, isDuplicateKeyError, isTransactionUnsupported, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, operationsByPolicyKey, parseDuplicateKeyError, prefixedId, repoOptionsFromCtx, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, systemContext, timestampPlugin, toPlain, uniqueField, validationChainPlugin, withTransaction };
@@ -1,4 +1,4 @@
1
- import { B as ObjectId, G as Plugin, Q as RepositoryContext } from "./types-DNFMofHy.mjs";
1
+ import { B as ObjectId, G as Plugin, Q as RepositoryContext } from "./types-BnRqAJVa.mjs";
2
2
  import mongoose from "mongoose";
3
3
  import { CacheAdapter as CacheAdapter$1, CacheOptions, RepositoryCacheHandle, RepositoryCachePluginOptions, cachePlugin } from "@classytic/repo-core/cache";
4
4
  import { TenantConfig } from "@classytic/repo-core/tenant";
@@ -1,2 +1,2 @@
1
- import { t as PaginationEngine } from "../PaginationEngine-DYpOD2wY.mjs";
1
+ import { t as PaginationEngine } from "../PaginationEngine-CYRTLW6s.mjs";
2
2
  export { PaginationEngine };
@@ -1,6 +1,6 @@
1
- import { G as Plugin } from "../types-DNFMofHy.mjs";
2
- import { C as AuditTrailMethods, E as auditTrailPlugin, S as AuditQueryResult, T as AuditTrailQuery, _ 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, l as customIdPlugin, m as CacheAdapter, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailOptions, x as AuditQueryOptions, y as AuditEntry } from "../multi-tenant.plugin-CTsWz0XK.mjs";
3
- import { C as LeasePluginOptions, D as elasticSearchPlugin, E as ElasticSearchOptions, M as auditLogPlugin, N as AggregateHelpersMethods, O as cascadePlugin, P as aggregateHelpersPlugin, S as LeaseMethods, T as fieldFilterPlugin, _ as observabilityPlugin, a as uniqueField, b as MethodRegistryRepository, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as batchOperationsPlugin, k as BatchOperationsMethods, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MongoOperationsMethods, w as leasePlugin, x as methodRegistryPlugin, y as mongoOperationsPlugin } from "../validation-chain.plugin-buy3uvyk.mjs";
1
+ import { G as Plugin } from "../types-BnRqAJVa.mjs";
2
+ import { C as AuditTrailMethods, E as auditTrailPlugin, S as AuditQueryResult, T as AuditTrailQuery, _ 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, l as customIdPlugin, m as CacheAdapter, o as IdGenerator, p as sequentialId, r as multiTenantPlugin, s as PrefixedIdOptions, t as MultiTenantOptions, u as dateSequentialId, v as cachePlugin, w as AuditTrailOptions, x as AuditQueryOptions, y as AuditEntry } from "../multi-tenant.plugin-CFzMOuZP.mjs";
3
+ import { A as elasticSearchPlugin, C as LeasePluginOptions, D as immutableStatesPlugin, E as ImmutableStatesPluginOptions, F as auditLogPlugin, I as AppendOnlyPluginOptions, L as appendOnlyPlugin, M as BatchOperationsMethods, O as fieldFilterPlugin, P as batchOperationsPlugin, R as AggregateHelpersMethods, S as LeaseMethods, T as ImmutableClaimView, _ as observabilityPlugin, a as uniqueField, b as MethodRegistryRepository, c as TenantContext, d as SubdocumentMethods, f as subdocumentPlugin, g as OperationMetric, h as ObservabilityOptions, i as requireField, j as cascadePlugin, k as ElasticSearchOptions, l as TenantStore, m as softDeletePlugin, n as blockIf, o as validationChainPlugin, p as SoftDeleteMethods, r as immutableField, s as timestampPlugin, t as autoInject, u as createTenantContext, v as MongoOperationsMethods, w as leasePlugin, x as methodRegistryPlugin, y as mongoOperationsPlugin, z as aggregateHelpersPlugin } from "../validation-chain.plugin-D-EjrYpR.mjs";
4
4
  import { ChangeLogStore } from "@classytic/repo-core/sync";
5
5
  //#region src/plugins/change-log.plugin.d.ts
6
6
  interface ChangeLogPluginOptions {
@@ -15,4 +15,4 @@ interface ChangeLogPluginOptions {
15
15
  }
16
16
  declare function changeLogPlugin(options: ChangeLogPluginOptions): Plugin;
17
17
  //#endregion
18
- export { type AggregateHelpersMethods, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type CacheAdapter, type CacheOptions, type ChangeLogPluginOptions, 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, changeLogPlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
18
+ export { type AggregateHelpersMethods, type AppendOnlyPluginOptions, type AuditEntry, type AuditOperation, type AuditQueryOptions, type AuditQueryResult, type AuditTrailMethods, type AuditTrailOptions, AuditTrailQuery, type BatchOperationsMethods, type CacheAdapter, type CacheOptions, type ChangeLogPluginOptions, type CustomIdOptions, type DateSequentialIdOptions, type ElasticSearchOptions, type IdGenerator, type ImmutableClaimView, type ImmutableStatesPluginOptions, 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, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, changeLogPlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, immutableStatesPlugin, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
@@ -1,5 +1,5 @@
1
- import { a as methodRegistryPlugin, c as getNextSequence, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, l as prefixedId, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, p as AuditTrailQuery, s as dateSequentialId, t as timestampPlugin, u as sequentialId } from "../timestamp.plugin-nG9Z1JEk.mjs";
2
- import { a as uniqueField, c as subdocumentPlugin, d as leasePlugin, f as fieldFilterPlugin, h as aggregateHelpersPlugin, i as requireField, l as observabilityPlugin, m as cascadePlugin, n as blockIf, o as validationChainPlugin, p as elasticSearchPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as mongoOperationsPlugin } from "../validation-chain.plugin-Dn_wZYLA.mjs";
1
+ import { a as methodRegistryPlugin, c as getNextSequence, d as cachePlugin, f as batchOperationsPlugin, h as auditLogPlugin, i as multiTenantPlugin, l as prefixedId, m as auditTrailPlugin, n as softDeletePlugin, o as customIdPlugin, p as AuditTrailQuery, s as dateSequentialId, t as timestampPlugin, u as sequentialId } from "../timestamp.plugin-Cn6LKUIZ.mjs";
2
+ import { _ as aggregateHelpersPlugin, a as uniqueField, c as subdocumentPlugin, d as leasePlugin, f as immutableStatesPlugin, g as appendOnlyPlugin, h as cascadePlugin, i as requireField, l as observabilityPlugin, m as elasticSearchPlugin, n as blockIf, o as validationChainPlugin, p as fieldFilterPlugin, r as immutableField, s as createTenantContext, t as autoInject, u as mongoOperationsPlugin } from "../validation-chain.plugin-D6qWMH5d.mjs";
3
3
  //#region src/plugins/change-log.plugin.ts
4
4
  const PLUGIN_NAME = "changeLog";
5
5
  function isSkipped(context) {
@@ -70,4 +70,4 @@ function changeLogPlugin(options) {
70
70
  };
71
71
  }
72
72
  //#endregion
73
- export { AuditTrailQuery, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, changeLogPlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
73
+ export { AuditTrailQuery, aggregateHelpersPlugin, appendOnlyPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, changeLogPlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, immutableStatesPlugin, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
@@ -1,4 +1,4 @@
1
- import { a as Repository, n as CreateRepositoryConfig } from "../create-repository-0TkQhcv-.mjs";
1
+ import { a as Repository, n as CreateRepositoryConfig } from "../create-repository-DXa3nMG6.mjs";
2
2
  import { Connection, Model, Schema } from "mongoose";
3
3
  import { MongoMemoryReplSet, MongoMemoryServer } from "mongodb-memory-server";
4
4
  //#region src/testkit/index.d.ts
@@ -1,4 +1,4 @@
1
- import { t as createRepository } from "../create-repository-CJATiAKX.mjs";
1
+ import { t as createRepository } from "../create-repository-DwODY4rZ.mjs";
2
2
  import { createConnection } from "mongoose";
3
3
  //#region src/testkit/index.ts
4
4
  function idempotentStop(server) {
@@ -1,4 +1,4 @@
1
- import { l as OP_REGISTRY, s as ALL_OPERATIONS, t as HOOK_PRIORITY } from "./Repository-dbbgOGjK.mjs";
1
+ import { l as OP_REGISTRY, s as ALL_OPERATIONS, t as HOOK_PRIORITY } from "./Repository-Dr1MDAen.mjs";
2
2
  import { n as warn } from "./logger-K7dPmu2U.mjs";
3
3
  import { t as createError } from "./error-BuByZwKU.mjs";
4
4
  import { throwIfAborted, withRetry } from "@classytic/repo-core/repository";
@@ -1,4 +1,4 @@
1
- import { C as FieldPreset, gt as UserContext } from "./types-DNFMofHy.mjs";
1
+ import { C as FieldPreset, gt as UserContext } from "./types-BnRqAJVa.mjs";
2
2
  import mongoose, { Schema } from "mongoose";
3
3
  import { CacheAdapter } from "@classytic/repo-core/cache";
4
4
  import { CrudSchemas, SchemaBuilderOptions } from "@classytic/repo-core/schema";
@@ -295,4 +295,33 @@ declare function buildCrudSchemasFromMongooseSchema(mongooseSchema: Schema, opti
295
295
  */
296
296
  declare function buildCrudSchemasFromModel(mongooseModel: mongoose.Model<unknown>, options?: SchemaBuilderOptions): CrudSchemasFramework;
297
297
  //#endregion
298
- export { IdType as a, isObjectIdInstance as c, filterResponseData as d, getFieldsForUser as f, parseDuplicateKeyError as g, isDuplicateKeyError as h, configureLogger as i, isValidIdForType as l, createError as m, buildCrudSchemasFromMongooseSchema as n, getSchemaIdType as o, getMongooseProjection as p, createMemoryCache as r, idVariants as s, buildCrudSchemasFromModel as t, createFieldPreset as u };
298
+ //#region src/utils/to-plain.d.ts
299
+ /**
300
+ * Convert a hydrated Mongoose (sub)document to a plain object — the
301
+ * spread-safety primitive for domain verbs that rebuild embedded lines.
302
+ *
303
+ * **The footgun this closes:** spreading a hydrated subdocument
304
+ * (`{ ...line, consumedQuantity: x }`) spreads its Mongoose INTERNAL
305
+ * properties (`$__`, `_doc`, ...), not its schema fields. The rebuilt
306
+ * object then casts to garbage on write — required fields land
307
+ * `undefined`, and because `findOneAndUpdate` does not run validators
308
+ * by default, the corrupt lines persist silently. This has bitten every
309
+ * package that maps over embedded arrays (`components`, `operations`,
310
+ * `revisions`) to produce an updated copy.
311
+ *
312
+ * Rule of thumb: **any `{ ...subdoc }` in a repository verb goes
313
+ * through `toPlain` first.**
314
+ *
315
+ * ```ts
316
+ * const updated = lines.map((line) => ({
317
+ * ...toPlain(line),
318
+ * reservedQuantity: reserved.get(line.itemSku) ?? 0,
319
+ * }));
320
+ * ```
321
+ *
322
+ * Non-documents pass through unchanged, so it is safe to apply
323
+ * defensively over values that may or may not be hydrated.
324
+ */
325
+ declare function toPlain<T>(value: T): T;
326
+ //#endregion
327
+ export { parseDuplicateKeyError as _, configureLogger as a, idVariants as c, createFieldPreset as d, filterResponseData as f, isDuplicateKeyError as g, createError as h, createMemoryCache as i, isObjectIdInstance as l, getMongooseProjection as m, buildCrudSchemasFromModel as n, IdType as o, getFieldsForUser as p, buildCrudSchemasFromMongooseSchema as r, getSchemaIdType as s, toPlain as t, isValidIdForType as u };
@@ -64,4 +64,35 @@ function createMemoryCache(maxEntries = 1e3) {
64
64
  };
65
65
  }
66
66
  //#endregion
67
- export { createMemoryCache as t };
67
+ //#region src/utils/to-plain.ts
68
+ /**
69
+ * Convert a hydrated Mongoose (sub)document to a plain object — the
70
+ * spread-safety primitive for domain verbs that rebuild embedded lines.
71
+ *
72
+ * **The footgun this closes:** spreading a hydrated subdocument
73
+ * (`{ ...line, consumedQuantity: x }`) spreads its Mongoose INTERNAL
74
+ * properties (`$__`, `_doc`, ...), not its schema fields. The rebuilt
75
+ * object then casts to garbage on write — required fields land
76
+ * `undefined`, and because `findOneAndUpdate` does not run validators
77
+ * by default, the corrupt lines persist silently. This has bitten every
78
+ * package that maps over embedded arrays (`components`, `operations`,
79
+ * `revisions`) to produce an updated copy.
80
+ *
81
+ * Rule of thumb: **any `{ ...subdoc }` in a repository verb goes
82
+ * through `toPlain` first.**
83
+ *
84
+ * ```ts
85
+ * const updated = lines.map((line) => ({
86
+ * ...toPlain(line),
87
+ * reservedQuantity: reserved.get(line.itemSku) ?? 0,
88
+ * }));
89
+ * ```
90
+ *
91
+ * Non-documents pass through unchanged, so it is safe to apply
92
+ * defensively over values that may or may not be hydrated.
93
+ */
94
+ function toPlain(value) {
95
+ return value !== null && value !== void 0 && typeof value.toObject === "function" ? value.toObject() : value;
96
+ }
97
+ //#endregion
98
+ export { createMemoryCache as n, toPlain as t };
@@ -1101,6 +1101,14 @@ interface SessionOptions {
1101
1101
  * ```
1102
1102
  */
1103
1103
  bypassTenant?: boolean;
1104
+ /**
1105
+ * Per-call escape hatch for `appendOnlyPlugin` — deliberate
1106
+ * maintenance on an immutable-facts collection (backfill repair,
1107
+ * migration). Audited via `after:append-only-bypass`; grep for this
1108
+ * flag the same way you grep `bypassTenant` / `mode: 'hard'`. NOT a
1109
+ * substitute for access control — gate it at the host layer.
1110
+ */
1111
+ bypassAppendOnly?: boolean;
1104
1112
  /** Extensible — plugins can read custom fields from options */
1105
1113
  [key: string]: unknown;
1106
1114
  }
@@ -0,0 +1,23 @@
1
+ import { Connection } from "mongoose";
2
+ import { UsageStore } from "@classytic/repo-core/usage";
3
+ //#region src/usage/index.d.ts
4
+ /** Adapter-construction options. */
5
+ interface MongoUsageStoreOptions {
6
+ /**
7
+ * Mongoose connection. Defaults to `mongoose.connection` (the
8
+ * default global connection). Apps using a named connection pass
9
+ * it explicitly.
10
+ */
11
+ connection?: Connection;
12
+ /** Collection name. Default `usage_counters`. */
13
+ collectionName?: string;
14
+ /** Override the Mongoose model name. Default `MongoUsageCounter`. */
15
+ modelName?: string;
16
+ }
17
+ /**
18
+ * Build a Mongo-backed usage store. Idempotent — the underlying model
19
+ * is registered once per `(connection, modelName)` pair.
20
+ */
21
+ declare function createMongoUsageStore(options?: MongoUsageStoreOptions): UsageStore;
22
+ //#endregion
23
+ export { MongoUsageStoreOptions, createMongoUsageStore };