@classytic/mongokit 3.29.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 (35) hide show
  1. package/README.md +43 -0
  2. package/dist/{create-repository-D4ZU94b3.d.mts → Repository-BXHkUtLk.d.mts} +30 -57
  3. package/dist/{Repository-DThvFCaV.mjs → Repository-X7U2d0kU.mjs} +296 -42
  4. package/dist/actions/index.mjs +1 -1
  5. package/dist/adapter/index.mjs +1 -1
  6. package/dist/{adapter-CLvUHiTW.mjs → adapter-BitHg-CN.mjs} +1 -1
  7. package/dist/ai/index.d.mts +1 -1
  8. package/dist/better-auth/index.d.mts +13 -0
  9. package/dist/better-auth/index.mjs +76 -6
  10. package/dist/create-repository-CvD4wzuN.d.mts +54 -0
  11. package/dist/{create-repository-uhKt_oUT.mjs → create-repository-DYe5YEie.mjs} +3 -2
  12. package/dist/index.d.mts +275 -41
  13. package/dist/index.mjs +80 -7
  14. package/dist/kernel-conformance/index.d.mts +217 -0
  15. package/dist/kernel-conformance/index.mjs +603 -0
  16. package/dist/method-registry.plugin-DblM7V6j.mjs +112 -0
  17. package/dist/model-registry-ClKtWiHa.mjs +67 -0
  18. package/dist/{mongooseToJsonSchema-CByt1VhQ.mjs → mongooseToJsonSchema-DKbnKduN.mjs} +14 -3
  19. package/dist/{multi-tenant.plugin-DVyVGREb.d.mts → multi-tenant.plugin-2VtSSm1Y.d.mts} +1 -1
  20. package/dist/outbox/index.d.mts +63 -0
  21. package/dist/outbox/index.mjs +239 -0
  22. package/dist/{plugin-options-vFufQZMZ.d.mts → plugin-options-BsFH0sTi.d.mts} +1 -1
  23. package/dist/plugins/index.d.mts +4 -4
  24. package/dist/plugins/index.mjs +3 -2
  25. package/dist/{repository-DCHRWRXw.d.mts → repository-Q16ErTu8.d.mts} +19 -1
  26. package/dist/testkit/index.d.mts +8 -1
  27. package/dist/testkit/index.mjs +1 -1
  28. package/dist/{timestamp.plugin-CFL6LlYZ.mjs → timestamp.plugin-ChFRcLRJ.mjs} +32 -143
  29. package/dist/{to-plain-DkF5px0R.d.mts → to-plain-BuX1RUZV.d.mts} +12 -4
  30. package/dist/{update-CI2NdAW6.mjs → update-DHdXdOk_.mjs} +21 -2
  31. package/dist/utils/index.d.mts +2 -2
  32. package/dist/utils/index.mjs +1 -1
  33. package/dist/{validation-chain.plugin-BLecaKa0.d.mts → validation-chain.plugin-BSshLJTA.d.mts} +3 -3
  34. package/dist/{validation-chain.plugin-CwOcUJC1.mjs → validation-chain.plugin-BxTl_dYR.mjs} +4 -3
  35. package/package.json +191 -185
@@ -1,6 +1,5 @@
1
- import { c as ALL_OPERATIONS, t as HOOK_PRIORITY, u as OP_REGISTRY } from "./Repository-DThvFCaV.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 };
@@ -77,9 +77,28 @@ function expandShorthands(obj) {
77
77
  }
78
78
  return out;
79
79
  }
80
- 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) {
81
100
  if (!input) return {};
82
- if (!isFilter(input)) return coerceFilterDates(expandShorthands(input));
101
+ if (!isFilter(input)) return coerceFilterDates(expandShorthands(input), schema ? { isDateField: schemaDateOracle(schema) } : void 0);
83
102
  return compile(input);
84
103
  }
85
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";
@@ -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 { IdempotencyStorePluginOptions as A, AppendOnlyPluginOptions as B, LeasePluginOptions as C, immutableStatesPlugin as D, ImmutableStatesPluginOptions as E, cascadePlugin as F, AggregateHelpersMethods as H, BatchOperationsMethods as I, BulkWriteResult as L, fieldFilterPlugin as M, ElasticSearchOptions as N, IdempotencyClaim as O, elasticSearchPlugin as P, batchOperationsPlugin as R, LeaseMethods as S, ImmutableClaimView 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, idempotencyStorePlugin as j, IdempotencyStoreMethods 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 };
@@ -1,5 +1,5 @@
1
- import { c as ALL_OPERATIONS, u as OP_REGISTRY } from "./Repository-DThvFCaV.mjs";
2
- import { _ as upsert } from "./update-CI2NdAW6.mjs";
1
+ import { c as ALL_OPERATIONS, u as OP_REGISTRY } from "./Repository-X7U2d0kU.mjs";
2
+ import { _ as upsert } from "./update-DHdXdOk_.mjs";
3
3
  import { n as warn } from "./logger-K7dPmu2U.mjs";
4
4
  import { t as createError } from "./error-BuByZwKU.mjs";
5
5
  import { r as getFieldsForUser } from "./field-selection-FSQFLpsU.mjs";
@@ -463,7 +463,8 @@ function fieldFilterPlugin(fieldPreset) {
463
463
  apply(repo) {
464
464
  const applyFieldFiltering = (context) => {
465
465
  if (!fieldPreset) return;
466
- const presetSelect = getFieldsForUser(context.context?.user || context.user, fieldPreset).join(" ");
466
+ const user = context.context?.user || context.user;
467
+ const presetSelect = getFieldsForUser(user, fieldPreset).join(" ");
467
468
  if (context.select) context.select = `${presetSelect} ${context.select}`;
468
469
  else context.select = presetSelect;
469
470
  };