@classytic/mongokit 3.28.0 → 3.30.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.
Files changed (37) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +54 -1
  3. package/TRADEMARK.md +22 -0
  4. package/dist/{create-repository-D4ZU94b3.d.mts → Repository-BXHkUtLk.d.mts} +30 -57
  5. package/dist/{Repository-BFBTAMlA.mjs → Repository-X7U2d0kU.mjs} +417 -47
  6. package/dist/actions/index.mjs +1 -1
  7. package/dist/adapter/index.mjs +1 -1
  8. package/dist/{adapter-CLvUHiTW.mjs → adapter-BitHg-CN.mjs} +1 -1
  9. package/dist/ai/index.d.mts +1 -1
  10. package/dist/better-auth/index.d.mts +13 -0
  11. package/dist/better-auth/index.mjs +76 -6
  12. package/dist/create-repository-CvD4wzuN.d.mts +54 -0
  13. package/dist/{create-repository-2DMwkYVz.mjs → create-repository-DYe5YEie.mjs} +3 -2
  14. package/dist/index.d.mts +275 -41
  15. package/dist/index.mjs +80 -7
  16. package/dist/kernel-conformance/index.d.mts +217 -0
  17. package/dist/kernel-conformance/index.mjs +603 -0
  18. package/dist/method-registry.plugin-DblM7V6j.mjs +112 -0
  19. package/dist/model-registry-ClKtWiHa.mjs +67 -0
  20. package/dist/{mongooseToJsonSchema-CByt1VhQ.mjs → mongooseToJsonSchema-DKbnKduN.mjs} +14 -3
  21. package/dist/{multi-tenant.plugin-DVyVGREb.d.mts → multi-tenant.plugin-2VtSSm1Y.d.mts} +1 -1
  22. package/dist/outbox/index.d.mts +63 -0
  23. package/dist/outbox/index.mjs +239 -0
  24. package/dist/{plugin-options-vFufQZMZ.d.mts → plugin-options-BsFH0sTi.d.mts} +1 -1
  25. package/dist/plugins/index.d.mts +4 -4
  26. package/dist/plugins/index.mjs +3 -2
  27. package/dist/{repository-DCHRWRXw.d.mts → repository-Q16ErTu8.d.mts} +19 -1
  28. package/dist/testkit/index.d.mts +8 -1
  29. package/dist/testkit/index.mjs +1 -1
  30. package/dist/{timestamp.plugin-ennbatTW.mjs → timestamp.plugin-ChFRcLRJ.mjs} +32 -143
  31. package/dist/{to-plain-DkF5px0R.d.mts → to-plain-BuX1RUZV.d.mts} +12 -4
  32. package/dist/{update-1Lq9OMD2.mjs → update-DHdXdOk_.mjs} +43 -30
  33. package/dist/utils/index.d.mts +2 -2
  34. package/dist/utils/index.mjs +1 -1
  35. package/dist/{validation-chain.plugin-Cm0Ttnd8.d.mts → validation-chain.plugin-BSshLJTA.d.mts} +44 -44
  36. package/dist/{validation-chain.plugin-k9joH2qw.mjs → validation-chain.plugin-BxTl_dYR.mjs} +139 -138
  37. package/package.json +28 -15
@@ -1,6 +1,5 @@
1
- import { c as ALL_OPERATIONS, t as HOOK_PRIORITY, u as OP_REGISTRY } from "./Repository-BFBTAMlA.mjs";
1
+ import { c as ALL_OPERATIONS, t as HOOK_PRIORITY, u as OP_REGISTRY } from "./Repository-X7U2d0kU.mjs";
2
2
  import { n as warn } from "./logger-K7dPmu2U.mjs";
3
- import { t as createError } from "./error-BuByZwKU.mjs";
4
3
  import { throwIfAborted, withRetry } from "@classytic/repo-core/repository";
5
4
  import mongoose from "mongoose";
6
5
  import { cachePlugin } from "@classytic/repo-core/cache";
@@ -632,81 +631,6 @@ var AuditTrailQuery = class {
632
631
  }
633
632
  };
634
633
  //#endregion
635
- //#region src/plugins/batch-operations.plugin.ts
636
- /**
637
- * Batch operations plugin.
638
- *
639
- * @example
640
- * const repo = new Repository(Model, [
641
- * methodRegistryPlugin(),
642
- * batchOperationsPlugin(),
643
- * ]);
644
- *
645
- * // updateMany + deleteMany are primitives on Repository — no plugin needed.
646
- * await repo.updateMany({ status: 'pending' }, { status: 'active' });
647
- * await repo.deleteMany({ status: 'deleted' });
648
- *
649
- * // bulkWrite is what this plugin contributes.
650
- * await repo.bulkWrite([...ops]);
651
- */
652
- function batchOperationsPlugin() {
653
- return {
654
- name: "batch-operations",
655
- apply(repo) {
656
- if (!repo.registerMethod) throw new Error("batchOperationsPlugin requires methodRegistryPlugin");
657
- /**
658
- * Execute heterogeneous bulk write operations in a single database call.
659
- *
660
- * Supports insertOne, updateOne, updateMany, deleteOne, deleteMany, and replaceOne
661
- * operations mixed together for maximum efficiency.
662
- *
663
- * @example
664
- * await repo.bulkWrite([
665
- * { insertOne: { document: { name: 'New Item', price: 10 } } },
666
- * { updateOne: { filter: { _id: id1 }, update: { $inc: { views: 1 } } } },
667
- * { updateMany: { filter: { status: 'draft' }, update: { $set: { status: 'published' } } } },
668
- * { deleteOne: { filter: { _id: id2 } } },
669
- * ]);
670
- */
671
- repo.registerMethod("bulkWrite", async function(operations, options = {}) {
672
- const context = await this._buildContext("bulkWrite", {
673
- operations,
674
- ...options
675
- });
676
- try {
677
- const finalOps = context.operations || operations;
678
- if (!finalOps || finalOps.length === 0) throw createError(400, "bulkWrite requires at least one operation");
679
- const result = await this.Model.bulkWrite(finalOps, {
680
- ordered: options.ordered ?? true,
681
- session: options.session
682
- });
683
- const bulkResult = {
684
- ok: result.ok,
685
- insertedCount: result.insertedCount,
686
- upsertedCount: result.upsertedCount,
687
- matchedCount: result.matchedCount,
688
- modifiedCount: result.modifiedCount,
689
- deletedCount: result.deletedCount,
690
- insertedIds: result.insertedIds,
691
- upsertedIds: result.upsertedIds
692
- };
693
- await this.emitAsync("after:bulkWrite", {
694
- context,
695
- result: bulkResult
696
- });
697
- return bulkResult;
698
- } catch (error) {
699
- this.emit("error:bulkWrite", {
700
- context,
701
- error
702
- });
703
- throw this._handleError(error);
704
- }
705
- });
706
- }
707
- };
708
- }
709
- //#endregion
710
634
  //#region src/plugins/custom-id.plugin.ts
711
635
  /**
712
636
  * Custom ID Plugin
@@ -893,7 +817,6 @@ function dateSequentialId(options) {
893
817
  default:
894
818
  datePart = `${year}${separator}${month}`;
895
819
  counterKey = `${model.modelName}:${year}-${month}`;
896
- break;
897
820
  }
898
821
  const seq = await getNextSequence(counterKey, 1, context._counterConnection, context.session);
899
822
  return `${prefix}${separator}${datePart}${separator}${String(seq).padStart(padding, "0")}`;
@@ -972,50 +895,18 @@ function customIdPlugin(options) {
972
895
  docsNeedingIds.push(doc);
973
896
  }
974
897
  if (docsNeedingIds.length === 0) return;
975
- for (const doc of docsNeedingIds) doc[fieldName] = await options.generator({
976
- ...context,
977
- data: doc
978
- });
898
+ for (const doc of docsNeedingIds) {
899
+ const id = await options.generator({
900
+ ...context,
901
+ data: doc
902
+ });
903
+ doc[fieldName] = id;
904
+ }
979
905
  });
980
906
  }
981
907
  };
982
908
  }
983
909
  //#endregion
984
- //#region src/plugins/method-registry.plugin.ts
985
- /**
986
- * Method registry plugin that enables dynamic method registration
987
- */
988
- function methodRegistryPlugin() {
989
- return {
990
- name: "method-registry",
991
- apply(repo) {
992
- const registeredMethods = [];
993
- /**
994
- * Register a new method on the repository instance
995
- */
996
- repo.registerMethod = (name, fn) => {
997
- if (repo[name]) throw new Error(`Cannot register method '${name}': Method already exists on repository. Choose a different name or use a plugin that doesn't conflict.`);
998
- if (!name || typeof name !== "string") throw new Error("Method name must be a non-empty string");
999
- if (typeof fn !== "function") throw new Error(`Method '${name}' must be a function`);
1000
- repo[name] = fn.bind(repo);
1001
- registeredMethods.push(name);
1002
- repo.emit("method:registered", {
1003
- name,
1004
- fn
1005
- });
1006
- };
1007
- /**
1008
- * Check if a method is registered
1009
- */
1010
- repo.hasMethod = (name) => typeof repo[name] === "function";
1011
- /**
1012
- * Get list of all dynamically registered methods
1013
- */
1014
- repo.getRegisteredMethods = () => [...registeredMethods];
1015
- }
1016
- };
1017
- }
1018
- //#endregion
1019
910
  //#region src/plugins/multi-tenant.plugin.ts
1020
911
  /**
1021
912
  * Multi-Tenant Plugin
@@ -1147,34 +1038,32 @@ function multiTenantPlugin(options = {}) {
1147
1038
  }
1148
1039
  }
1149
1040
  break;
1150
- case "operations":
1151
- if (context.operations) {
1152
- const ops = context.operations;
1153
- for (const subOp of ops) {
1154
- for (const key of [
1155
- "updateOne",
1156
- "updateMany",
1157
- "deleteOne",
1158
- "deleteMany",
1159
- "replaceOne"
1160
- ]) {
1161
- const opBody = subOp[key];
1162
- if (opBody?.filter) {
1163
- assertTenantValue(opBody.filter[tenantField], `bulkWrite ${key}.filter`);
1164
- opBody.filter = {
1165
- ...opBody.filter,
1166
- [tenantField]: castId
1167
- };
1168
- }
1169
- }
1170
- const insertBody = subOp.insertOne;
1171
- if (insertBody?.document) {
1172
- assertTenantValue(insertBody.document[tenantField], "bulkWrite insertOne.document");
1173
- insertBody.document[tenantField] = castId;
1041
+ case "operations": if (context.operations) {
1042
+ const ops = context.operations;
1043
+ for (const subOp of ops) {
1044
+ for (const key of [
1045
+ "updateOne",
1046
+ "updateMany",
1047
+ "deleteOne",
1048
+ "deleteMany",
1049
+ "replaceOne"
1050
+ ]) {
1051
+ const opBody = subOp[key];
1052
+ if (opBody?.filter) {
1053
+ assertTenantValue(opBody.filter[tenantField], `bulkWrite ${key}.filter`);
1054
+ opBody.filter = {
1055
+ ...opBody.filter,
1056
+ [tenantField]: castId
1057
+ };
1174
1058
  }
1175
1059
  }
1060
+ const insertBody = subOp.insertOne;
1061
+ if (insertBody?.document) {
1062
+ assertTenantValue(insertBody.document[tenantField], "bulkWrite insertOne.document");
1063
+ insertBody.document[tenantField] = castId;
1064
+ }
1176
1065
  }
1177
- break;
1066
+ }
1178
1067
  }
1179
1068
  }, { priority: HOOK_PRIORITY.POLICY });
1180
1069
  }
@@ -1542,4 +1431,4 @@ function timestampPlugin() {
1542
1431
  };
1543
1432
  }
1544
1433
  //#endregion
1545
- export { methodRegistryPlugin as a, getNextSequence as c, cachePlugin as d, batchOperationsPlugin as f, auditLogPlugin as g, ensureAuditTrailReady as h, multiTenantPlugin as i, prefixedId as l, auditTrailPlugin as m, softDeletePlugin as n, customIdPlugin as o, AuditTrailQuery as p, adminBypass$1 as r, dateSequentialId as s, timestampPlugin as t, sequentialId as u };
1434
+ export { customIdPlugin as a, prefixedId as c, AuditTrailQuery as d, auditTrailPlugin as f, multiTenantPlugin as i, sequentialId as l, auditLogPlugin as m, softDeletePlugin as n, dateSequentialId as o, ensureAuditTrailReady as p, adminBypass$1 as r, getNextSequence as s, timestampPlugin as t, cachePlugin as u };
@@ -1,5 +1,5 @@
1
- import { v as UserContext } from "./repository-DCHRWRXw.mjs";
2
- import { r as FieldPreset } from "./plugin-options-vFufQZMZ.mjs";
1
+ import { v as UserContext } from "./repository-Q16ErTu8.mjs";
2
+ import { r as FieldPreset } from "./plugin-options-BsFH0sTi.mjs";
3
3
  import mongoose, { Schema } from "mongoose";
4
4
  import { CacheAdapter } from "@classytic/repo-core/cache";
5
5
  import { CrudSchemas, SchemaBuilderOptions } from "@classytic/repo-core/schema";
@@ -288,8 +288,16 @@ declare function buildCrudSchemasFromMongooseSchema(mongooseSchema: Schema, opti
288
288
  * field accepts this function directly with no glue. Future Mongo-shaped
289
289
  * kits implementing the same contract are interchangeable at the adapter
290
290
  * boundary.
291
+ *
292
+ * GENERIC over the document type, not fixed to `Model<unknown>`. Only
293
+ * `.schema` is read, so the document type is irrelevant here — but Mongoose's
294
+ * `Model<T>` is INVARIANT through `schema.static`, so a hard `Model<unknown>`
295
+ * parameter rejects every concretely-typed model a host actually has. That is
296
+ * not theoretical: it made `arc init`'s generated `example.schemas.ts` fail
297
+ * `tsc` on a brand-new project. Instantiating `TDoc = unknown` still satisfies
298
+ * `SchemaGenerator<Model<unknown>>`, so the contract claim above is unchanged.
291
299
  */
292
- declare function buildCrudSchemasFromModel(mongooseModel: mongoose.Model<unknown>, options?: SchemaBuilderOptions): CrudSchemasFramework;
300
+ declare function buildCrudSchemasFromModel<TDoc = unknown>(mongooseModel: mongoose.Model<TDoc>, options?: SchemaBuilderOptions): CrudSchemasFramework;
293
301
  //#endregion
294
302
  //#region src/utils/to-plain.d.ts
295
303
  /**
@@ -320,4 +328,4 @@ declare function buildCrudSchemasFromModel(mongooseModel: mongoose.Model<unknown
320
328
  */
321
329
  declare function toPlain<T>(value: T): T;
322
330
  //#endregion
323
- export { isDuplicateKeyError as _, configureLogger as a, idVariants as c, toObjectId as d, createFieldPreset as f, createError as g, getMongooseProjection as h, createMemoryCache as i, isObjectIdInstance as l, getFieldsForUser as m, buildCrudSchemasFromModel as n, IdType as o, filterResponseData as p, buildCrudSchemasFromMongooseSchema as r, getSchemaIdType as s, toPlain as t, isValidIdForType as u, parseDuplicateKeyError as v };
331
+ export { parseDuplicateKeyError as S, getMongooseProjection as _, createMemoryCache as a, createError as b, IdType as c, isObjectIdInstance as d, isValidIdForType as f, getFieldsForUser as g, filterResponseData as h, buildCrudSchemasFromMongooseSchema as i, getSchemaIdType as l, createFieldPreset as m, CrudSchemasFramework as n, LoggerConfig as o, toObjectId as p, buildCrudSchemasFromModel as r, configureLogger as s, toPlain as t, idVariants as u, CreateErrorOptions as v, isDuplicateKeyError as x, ParseDuplicateKeyOptions as y };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { n as warn } from "./logger-K7dPmu2U.mjs";
3
3
  import { t as createError } from "./error-BuByZwKU.mjs";
4
- import { isFilter } from "@classytic/repo-core/filter";
4
+ import { coerceFilterDates, isFilter } from "@classytic/repo-core/filter";
5
5
  //#region src/filter/compile.ts
6
6
  /**
7
7
  * Compile a Filter IR node to a MongoDB query object. Returns `{}`
@@ -34,47 +34,41 @@ const SHORTHAND_OPS = /* @__PURE__ */ new Set([
34
34
  "regex",
35
35
  "mod"
36
36
  ]);
37
- /** Range operators whose string values should be coerced to Date. */
38
- const RANGE_OPS = /* @__PURE__ */ new Set([
39
- "gt",
40
- "gte",
41
- "lt",
42
- "lte"
37
+ /** Logical operators whose operand is an array of sub-queries to recurse into. */
38
+ const LOGICAL_ARRAY_OPS = /* @__PURE__ */ new Set([
39
+ "$and",
40
+ "$or",
41
+ "$nor"
43
42
  ]);
44
- /** ISO-8601 date-only or datetime string pattern. */
45
- const ISO_DATE_RE = /^\d{4}-\d{2}-\d{2}/;
46
- /**
47
- * Coerce a string value to a Date when it looks like an ISO-8601 date.
48
- * Needed because MongoDB won't match a BSON Date field against a string
49
- * value even when using range operators — BSON type comparison treats
50
- * Date (type 9) and String (type 2) as distinct, so `{ createdAt: {
51
- * $gte: "2026-05-01" } }` never matches a Date-typed field.
52
- */
53
- function tryCoerceDate(value) {
54
- if (typeof value === "string" && ISO_DATE_RE.test(value)) {
55
- const d = new Date(value);
56
- return Number.isNaN(d.getTime()) ? value : d;
57
- }
58
- return value;
59
- }
60
43
  /**
61
- * Expand operator shorthand values in a plain Mongo-style query object.
44
+ * Expand operator shorthand values in a plain Mongo-style query object —
45
+ * `$`-prefixing is the ONE Mongo-dialect concern this function owns. Date
46
+ * coercion is delegated to `coerceFilterDates` (repo-core) so the ISO
47
+ * pattern has a single source of truth shared with the URL-parsing boundary.
48
+ *
62
49
  * Only expands nested objects whose keys are ALL in `SHORTHAND_OPS` — so
63
50
  * real nested documents (e.g. `address: { city: 'Dhaka' }`) pass through
64
51
  * unchanged, while `createdAt: { gte: '2026-04-01', lte: '2026-05-01' }`
65
- * becomes `createdAt: { $gte: Date(2026-04-01), $lte: Date(2026-05-01) }`.
66
- * String values on range operators are coerced to Date when they match the
67
- * ISO-8601 pattern, so BSON Date fields in MongoDB are compared correctly.
52
+ * becomes `createdAt: { $gte: '2026-04-01', $lte: '2026-05-01' }` for the
53
+ * coercion pass to type.
54
+ *
55
+ * Recurses `$and` / `$or` / `$nor` because a policy-scope merge conjoins the
56
+ * caller filter under `$and`, and un-prefixed shorthand nested there would
57
+ * otherwise reach `$match` as a literal field named `gte`.
68
58
  */
69
59
  function expandShorthands(obj) {
70
60
  const out = {};
71
61
  for (const [key, value] of Object.entries(obj)) {
62
+ if (LOGICAL_ARRAY_OPS.has(key) && Array.isArray(value)) {
63
+ out[key] = value.map((entry) => entry !== null && typeof entry === "object" && !Array.isArray(entry) ? expandShorthands(entry) : entry);
64
+ continue;
65
+ }
72
66
  if (value !== null && typeof value === "object" && !Array.isArray(value)) {
73
67
  const nested = value;
74
68
  const keys = Object.keys(nested);
75
69
  if (keys.length > 0 && keys.every((k) => !k.startsWith("$") && SHORTHAND_OPS.has(k))) {
76
70
  const expanded = {};
77
- for (const [op, opVal] of Object.entries(nested)) expanded[`$${op}`] = RANGE_OPS.has(op) ? tryCoerceDate(opVal) : opVal;
71
+ for (const [op, opVal] of Object.entries(nested)) expanded[`$${op}`] = opVal;
78
72
  out[key] = expanded;
79
73
  continue;
80
74
  }
@@ -83,9 +77,28 @@ function expandShorthands(obj) {
83
77
  }
84
78
  return out;
85
79
  }
86
- function compileFilterToMongo(input) {
80
+ /**
81
+ * Build the schema oracle `coerceFilterDates` needs from a mongoose schema.
82
+ *
83
+ * A path is date-coercible only when the schema says it is a Date. Everything else — most
84
+ * importantly a `String` path whose values are ISO-shaped, like a `civilDate` of
85
+ * `'2026-08-02'` — keeps its operand verbatim.
86
+ *
87
+ * Unknown paths default to TRUE (coerce). A filter on a path the schema does not declare
88
+ * is usually a `strict: false` extension or a nested/dynamic key, and the old
89
+ * value-shape-only behaviour is the safer default there: coercing a genuine date string is
90
+ * right far more often than not for an undeclared path.
91
+ */
92
+ function schemaDateOracle(schema) {
93
+ return (field) => {
94
+ const path = schema.path(field);
95
+ if (!path) return true;
96
+ return path.instance === "Date";
97
+ };
98
+ }
99
+ function compileFilterToMongo(input, schema) {
87
100
  if (!input) return {};
88
- if (!isFilter(input)) return expandShorthands(input);
101
+ if (!isFilter(input)) return coerceFilterDates(expandShorthands(input), schema ? { isDateField: schemaDateOracle(schema) } : void 0);
89
102
  return compile(input);
90
103
  }
91
104
  function compile(filter) {
@@ -1,2 +1,2 @@
1
- import { a as configureLogger, d as toObjectId, f as createFieldPreset, g as createError, h as getMongooseProjection, i as createMemoryCache, l as isObjectIdInstance, m as getFieldsForUser, n as buildCrudSchemasFromModel, o as IdType, p as filterResponseData, r as buildCrudSchemasFromMongooseSchema, s as getSchemaIdType, t as toPlain, u as isValidIdForType } from "../to-plain-DkF5px0R.mjs";
2
- export { type IdType, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, configureLogger, createError, createFieldPreset, createMemoryCache, filterResponseData, getFieldsForUser, getMongooseProjection, getSchemaIdType, isObjectIdInstance, isValidIdForType, toObjectId, toPlain };
1
+ import { _ as getMongooseProjection, a as createMemoryCache, b as createError, c as IdType, d as isObjectIdInstance, f as isValidIdForType, g as getFieldsForUser, h as filterResponseData, i as buildCrudSchemasFromMongooseSchema, l as getSchemaIdType, m as createFieldPreset, n as CrudSchemasFramework, o as LoggerConfig, p as toObjectId, r as buildCrudSchemasFromModel, s as configureLogger, t as toPlain, v as CreateErrorOptions, y as ParseDuplicateKeyOptions } from "../to-plain-BuX1RUZV.mjs";
2
+ export { type CreateErrorOptions, type CrudSchemasFramework, type IdType, type LoggerConfig, type ParseDuplicateKeyOptions, buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, configureLogger, createError, createFieldPreset, createMemoryCache, filterResponseData, getFieldsForUser, getMongooseProjection, getSchemaIdType, isObjectIdInstance, isValidIdForType, toObjectId, toPlain };
@@ -3,5 +3,5 @@ import { t as configureLogger } from "../logger-K7dPmu2U.mjs";
3
3
  import { t as createError } from "../error-BuByZwKU.mjs";
4
4
  import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "../field-selection-FSQFLpsU.mjs";
5
5
  import { n as createMemoryCache, t as toPlain } from "../to-plain-vksRrLtc.mjs";
6
- import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-CByt1VhQ.mjs";
6
+ import { n as buildCrudSchemasFromMongooseSchema, t as buildCrudSchemasFromModel } from "../mongooseToJsonSchema-DKbnKduN.mjs";
7
7
  export { buildCrudSchemasFromModel, buildCrudSchemasFromMongooseSchema, configureLogger, createError, createFieldPreset, createMemoryCache, filterResponseData, getFieldsForUser, getMongooseProjection, getSchemaIdType, isObjectIdInstance, isValidIdForType, toObjectId, toPlain };
@@ -1,6 +1,6 @@
1
1
  import { a as PopulateSpec, i as ObjectId, l as SortSpec, s as SelectSpec } from "./core-62oo3N1C.mjs";
2
- import { h as RepositoryInstance, l as Plugin, p as RepositoryContext } from "./repository-DCHRWRXw.mjs";
3
- import { c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, o as SoftDeleteOptions, r as FieldPreset, t as CascadeOptions } from "./plugin-options-vFufQZMZ.mjs";
2
+ import { h as RepositoryInstance, l as Plugin, p as RepositoryContext } from "./repository-Q16ErTu8.mjs";
3
+ import { c as ValidationChainOptions, i as Logger, l as ValidatorDefinition, o as SoftDeleteOptions, r as FieldPreset, t as CascadeOptions } from "./plugin-options-BsFH0sTi.mjs";
4
4
  import { BulkWriteResult } from "@classytic/repo-core/repository";
5
5
  import { AsyncLocalStorage } from "node:async_hooks";
6
6
  import { OffsetPaginationResult } from "@classytic/repo-core/pagination";
@@ -185,47 +185,6 @@ declare function elasticSearchPlugin(options: ElasticSearchOptions): Plugin;
185
185
  */
186
186
  declare function fieldFilterPlugin(fieldPreset: FieldPreset): Plugin;
187
187
  //#endregion
188
- //#region src/plugins/immutable-states.plugin.d.ts
189
- /** The slice of a `before:claim` context `allowClaim` predicates see. */
190
- interface ImmutableClaimView {
191
- id: unknown;
192
- transition: {
193
- from?: unknown | readonly unknown[];
194
- to?: unknown;
195
- field?: string;
196
- where?: Record<string, unknown>;
197
- };
198
- /** Operator-form patch (`{ $set: {...}, ... }`). */
199
- data: Record<string, unknown> | undefined;
200
- }
201
- interface ImmutableStatesPluginOptions {
202
- /** States in which the document is frozen (e.g. `['posted']`). */
203
- states: readonly string[];
204
- /** State field on the doc — dotted paths supported. Default `'state'`. */
205
- field?: string | undefined;
206
- /**
207
- * Context flag the OWNING ENGINE's verbs set to pass the guard
208
- * (private handshake — see module doc). Default `'_immutableInternal'`.
209
- */
210
- internalFlag?: string | undefined;
211
- /** Tenant field used to scope state lookups (mirrors the repo's scope). */
212
- tenantField?: string | undefined;
213
- /**
214
- * Exempt specific claim shapes that legitimately touch frozen rows
215
- * (audit-trail stamps like ledger's reverse-mark). Return `true` to
216
- * allow. Runs only after the claim was determined to reach a frozen
217
- * state — keep the predicate a strict fingerprint.
218
- */
219
- allowClaim?: ((view: ImmutableClaimView) => boolean) | undefined;
220
- /** Domain error to throw. Default: 403 `IMMUTABLE_STATE_VIOLATION`. */
221
- errorFactory?: ((ctx: {
222
- id: unknown;
223
- operation: string;
224
- state?: string | undefined;
225
- }) => Error) | undefined;
226
- }
227
- declare function immutableStatesPlugin(options: ImmutableStatesPluginOptions): Plugin;
228
- //#endregion
229
188
  //#region src/plugins/idempotency-store.plugin.d.ts
230
189
  interface IdempotencyStorePluginOptions {
231
190
  /** Field carrying the deterministic operation key. @default `'key'` */
@@ -362,6 +321,47 @@ interface IdempotencyStoreMethods<TProgress = Record<string, unknown>, TResult =
362
321
  }
363
322
  declare function idempotencyStorePlugin(options?: IdempotencyStorePluginOptions): Plugin;
364
323
  //#endregion
324
+ //#region src/plugins/immutable-states.plugin.d.ts
325
+ /** The slice of a `before:claim` context `allowClaim` predicates see. */
326
+ interface ImmutableClaimView {
327
+ id: unknown;
328
+ transition: {
329
+ from?: unknown | readonly unknown[];
330
+ to?: unknown;
331
+ field?: string;
332
+ where?: Record<string, unknown>;
333
+ };
334
+ /** Operator-form patch (`{ $set: {...}, ... }`). */
335
+ data: Record<string, unknown> | undefined;
336
+ }
337
+ interface ImmutableStatesPluginOptions {
338
+ /** States in which the document is frozen (e.g. `['posted']`). */
339
+ states: readonly string[];
340
+ /** State field on the doc — dotted paths supported. Default `'state'`. */
341
+ field?: string | undefined;
342
+ /**
343
+ * Context flag the OWNING ENGINE's verbs set to pass the guard
344
+ * (private handshake — see module doc). Default `'_immutableInternal'`.
345
+ */
346
+ internalFlag?: string | undefined;
347
+ /** Tenant field used to scope state lookups (mirrors the repo's scope). */
348
+ tenantField?: string | undefined;
349
+ /**
350
+ * Exempt specific claim shapes that legitimately touch frozen rows
351
+ * (audit-trail stamps like ledger's reverse-mark). Return `true` to
352
+ * allow. Runs only after the claim was determined to reach a frozen
353
+ * state — keep the predicate a strict fingerprint.
354
+ */
355
+ allowClaim?: ((view: ImmutableClaimView) => boolean) | undefined;
356
+ /** Domain error to throw. Default: 403 `IMMUTABLE_STATE_VIOLATION`. */
357
+ errorFactory?: ((ctx: {
358
+ id: unknown;
359
+ operation: string;
360
+ state?: string | undefined;
361
+ }) => Error) | undefined;
362
+ }
363
+ declare function immutableStatesPlugin(options: ImmutableStatesPluginOptions): Plugin;
364
+ //#endregion
365
365
  //#region src/plugins/lease.plugin.d.ts
366
366
  interface LeasePluginOptions {
367
367
  /** Field carrying the row's status. @default `'status'` */
@@ -958,4 +958,4 @@ declare function immutableField(field: string): ValidatorDefinition;
958
958
  */
959
959
  declare function uniqueField(field: string, errorMessage?: string): ValidatorDefinition;
960
960
  //#endregion
961
- export { ImmutableStatesPluginOptions as A, AppendOnlyPluginOptions as B, LeasePluginOptions as C, IdempotencyStorePluginOptions as D, IdempotencyStoreMethods as E, cascadePlugin as F, AggregateHelpersMethods as H, BatchOperationsMethods as I, BulkWriteResult as L, fieldFilterPlugin as M, ElasticSearchOptions as N, idempotencyStorePlugin as O, elasticSearchPlugin as P, batchOperationsPlugin as R, LeaseMethods as S, IdempotencyClaim as T, aggregateHelpersPlugin as U, appendOnlyPlugin as V, observabilityPlugin as _, uniqueField as a, MethodRegistryRepository as b, TenantContext as c, SubdocumentMethods as d, subdocumentPlugin as f, OperationMetric as g, ObservabilityOptions as h, requireField as i, immutableStatesPlugin as j, ImmutableClaimView as k, TenantStore as l, softDeletePlugin as m, blockIf as n, validationChainPlugin as o, SoftDeleteMethods as p, immutableField as r, timestampPlugin as s, autoInject as t, createTenantContext as u, MongoOperationsMethods as v, leasePlugin as w, methodRegistryPlugin as x, mongoOperationsPlugin as y, auditLogPlugin as z };
961
+ export { IdempotencyStoreMethods as A, auditLogPlugin as B, LeaseMethods as C, ImmutableStatesPluginOptions as D, ImmutableClaimView as E, elasticSearchPlugin as F, appendOnlyPlugin as H, cascadePlugin as I, BatchOperationsMethods as L, idempotencyStorePlugin as M, fieldFilterPlugin as N, immutableStatesPlugin as O, ElasticSearchOptions as P, BulkWriteResult as R, methodRegistryPlugin as S, leasePlugin as T, AggregateHelpersMethods as U, AppendOnlyPluginOptions as V, aggregateHelpersPlugin as W, OperationMetric as _, requireField as a, mongoOperationsPlugin as b, timestampPlugin as c, createTenantContext as d, SubdocumentMethods as f, ObservabilityOptions as g, softDeletePlugin as h, immutableField as i, IdempotencyStorePluginOptions as j, IdempotencyClaim as k, TenantContext as l, SoftDeleteMethods as m, autoInject as n, uniqueField as o, subdocumentPlugin as p, blockIf as r, validationChainPlugin as s, OperationType as t, TenantStore as u, observabilityPlugin as v, LeasePluginOptions as w, MethodRegistryRepository as x, MongoOperationsMethods as y, batchOperationsPlugin as z };