@classytic/mongokit 3.13.2 → 3.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Repository-DwJFh3XA.mjs → Repository-CNBTCVat.mjs} +27 -5
- package/dist/better-auth/index.mjs +1 -1
- package/dist/index.d.mts +15 -1
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.mjs +1 -1
- package/dist/{validation-chain.plugin-Pj2aD17U.mjs → validation-chain.plugin-Bbbnq8ay.mjs} +1 -1
- package/package.json +3 -3
|
@@ -2018,6 +2018,8 @@ var Repository = class extends RepositoryBase {
|
|
|
2018
2018
|
if (context.lean ?? options.lean ?? true) query.lean();
|
|
2019
2019
|
if (options.session) query.session(options.session);
|
|
2020
2020
|
if (options.readPreference) query.read(options.readPreference);
|
|
2021
|
+
const limitSpec = context.limit ?? options.limit;
|
|
2022
|
+
if (typeof limitSpec === "number" && limitSpec > 0) query.limit(limitSpec);
|
|
2021
2023
|
return await query.exec();
|
|
2022
2024
|
});
|
|
2023
2025
|
}
|
|
@@ -2126,10 +2128,14 @@ var Repository = class extends RepositoryBase {
|
|
|
2126
2128
|
});
|
|
2127
2129
|
return cachedResult;
|
|
2128
2130
|
});
|
|
2129
|
-
if (params.noPagination)
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2131
|
+
if (params.noPagination) {
|
|
2132
|
+
const forwardedLimit = context.limit ?? params.limit ?? params.pagination?.limit;
|
|
2133
|
+
return this.findAll(context.filters ?? params.filters ?? {}, {
|
|
2134
|
+
...options,
|
|
2135
|
+
sort: context.sort ?? params.sort,
|
|
2136
|
+
...typeof forwardedLimit === "number" ? { limit: forwardedLimit } : {}
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2133
2139
|
const filters = context.filters ?? params.filters ?? {};
|
|
2134
2140
|
const search = context.search;
|
|
2135
2141
|
const isNearQuery = hasNearOperator(filters);
|
|
@@ -3594,9 +3600,25 @@ var Repository = class extends RepositoryBase {
|
|
|
3594
3600
|
return isDuplicateKeyError(err);
|
|
3595
3601
|
}
|
|
3596
3602
|
/**
|
|
3597
|
-
* Handle errors with proper HTTP status codes
|
|
3603
|
+
* Handle errors with proper HTTP status codes.
|
|
3604
|
+
*
|
|
3605
|
+
* **Transactional retry signal preservation.** MongoDB driver errors
|
|
3606
|
+
* carry `errorLabels` (e.g. `'TransientTransactionError'`,
|
|
3607
|
+
* `'UnknownTransactionCommitResult'`) that `mongoose.Connection.
|
|
3608
|
+
* withTransaction()` reads via `error.hasErrorLabel(label)` to decide
|
|
3609
|
+
* whether to auto-retry the transaction. Wrapping such an error in a
|
|
3610
|
+
* fresh `Error` via `createError(...)` strips both the labels and the
|
|
3611
|
+
* `hasErrorLabel` method — the retry signal vanishes and concurrent
|
|
3612
|
+
* writers see WriteConflicts surface to userland instead of being
|
|
3613
|
+
* retried by the driver. To keep the standard MongoDB transaction-
|
|
3614
|
+
* retry mechanism intact, we re-throw any error that carries
|
|
3615
|
+
* `errorLabels` exactly as we received it. The caller still sees a
|
|
3616
|
+
* thrown error — only the wrapping layer is skipped.
|
|
3598
3617
|
*/
|
|
3599
3618
|
_handleError(error) {
|
|
3619
|
+
const labels = error.errorLabels;
|
|
3620
|
+
const hasLabel = error.hasErrorLabel;
|
|
3621
|
+
if (Array.isArray(labels) && (labels.includes("TransientTransactionError") || labels.includes("UnknownTransactionCommitResult")) || typeof hasLabel === "function" && (hasLabel.call(error, "TransientTransactionError") || hasLabel.call(error, "UnknownTransactionCommitResult"))) return error;
|
|
3600
3622
|
if (error instanceof mongoose.Error.ValidationError) return createError(400, `Validation Error: ${Object.values(error.errors).map((err) => err.message).join(", ")}`);
|
|
3601
3623
|
if (error instanceof mongoose.Error.CastError) return createError(400, `Invalid ${error.path}: ${error.value}`);
|
|
3602
3624
|
const duplicateErr = parseDuplicateKeyError(error);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Repository } from "../Repository-
|
|
1
|
+
import { n as Repository } from "../Repository-CNBTCVat.mjs";
|
|
2
2
|
import { n as createMongooseAdapter } from "../adapter-DTDMnUOH.mjs";
|
|
3
3
|
import { pluralizeBetterAuthCollection, resolveBetterAuthCollections } from "@classytic/repo-core/better-auth";
|
|
4
4
|
//#region src/better-auth/index.ts
|
package/dist/index.d.mts
CHANGED
|
@@ -1115,6 +1115,7 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
|
|
|
1115
1115
|
*/
|
|
1116
1116
|
findAll(filters?: Record<string, unknown>, options?: OperationOptions & {
|
|
1117
1117
|
sort?: SortSpec | string;
|
|
1118
|
+
limit?: number;
|
|
1118
1119
|
}): Promise<TDoc[]>;
|
|
1119
1120
|
/**
|
|
1120
1121
|
* Streaming reads — async iterator over data, suitable for migrations,
|
|
@@ -1894,7 +1895,20 @@ declare class Repository<TDoc = unknown> extends RepositoryBase {
|
|
|
1894
1895
|
*/
|
|
1895
1896
|
isDuplicateKeyError(err: unknown): boolean;
|
|
1896
1897
|
/**
|
|
1897
|
-
* Handle errors with proper HTTP status codes
|
|
1898
|
+
* Handle errors with proper HTTP status codes.
|
|
1899
|
+
*
|
|
1900
|
+
* **Transactional retry signal preservation.** MongoDB driver errors
|
|
1901
|
+
* carry `errorLabels` (e.g. `'TransientTransactionError'`,
|
|
1902
|
+
* `'UnknownTransactionCommitResult'`) that `mongoose.Connection.
|
|
1903
|
+
* withTransaction()` reads via `error.hasErrorLabel(label)` to decide
|
|
1904
|
+
* whether to auto-retry the transaction. Wrapping such an error in a
|
|
1905
|
+
* fresh `Error` via `createError(...)` strips both the labels and the
|
|
1906
|
+
* `hasErrorLabel` method — the retry signal vanishes and concurrent
|
|
1907
|
+
* writers see WriteConflicts surface to userland instead of being
|
|
1908
|
+
* retried by the driver. To keep the standard MongoDB transaction-
|
|
1909
|
+
* retry mechanism intact, we re-throw any error that carries
|
|
1910
|
+
* `errorLabels` exactly as we received it. The caller still sees a
|
|
1911
|
+
* thrown error — only the wrapping layer is skipped.
|
|
1898
1912
|
*/
|
|
1899
1913
|
_handleError(error: Error): HttpError;
|
|
1900
1914
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -2,9 +2,9 @@ import { b as LookupBuilder, x as compileFilterToMongo } from "./update-C-3viiw1
|
|
|
2
2
|
import { n as warn, t as configureLogger } from "./logger-DprijP5h.mjs";
|
|
3
3
|
import { n as isDuplicateKeyError, r as parseDuplicateKeyError, t as createError } from "./error-B00pI7dV.mjs";
|
|
4
4
|
import { t as actions_exports } from "./actions/index.mjs";
|
|
5
|
-
import { a as withTransaction, c as MUTATING_OPERATIONS, d as operationsByPolicyKey, i as isTransactionUnsupported, l as OP_REGISTRY, n as Repository, o as AggregationBuilder, r as batchTransaction, s as ALL_OPERATIONS, t as HOOK_PRIORITY, u as READ_OPERATIONS } from "./Repository-
|
|
5
|
+
import { a as withTransaction, c as MUTATING_OPERATIONS, d as operationsByPolicyKey, i as isTransactionUnsupported, l as OP_REGISTRY, n as Repository, o as AggregationBuilder, r as batchTransaction, s as ALL_OPERATIONS, t as HOOK_PRIORITY, u as READ_OPERATIONS } from "./Repository-CNBTCVat.mjs";
|
|
6
6
|
import { t as PaginationEngine } from "./PaginationEngine-CfQRM1yz.mjs";
|
|
7
|
-
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, f as adminBypass, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "./validation-chain.plugin-
|
|
7
|
+
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, f as adminBypass, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "./validation-chain.plugin-Bbbnq8ay.mjs";
|
|
8
8
|
import { i as getMongooseProjection, n as filterResponseData, r as getFieldsForUser, t as createFieldPreset } from "./field-selection-Br3WPOEb.mjs";
|
|
9
9
|
import { isGeoOperator, parseGeoFilter } from "./query/primitives/geo.mjs";
|
|
10
10
|
import { buildFieldTypeMap, coerceFieldValue, coerceHeuristic } from "./query/primitives/coercion.mjs";
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "../validation-chain.plugin-
|
|
1
|
+
import { A as aggregateHelpersPlugin, C as sequentialId, D as AuditTrailQuery, E as batchOperationsPlugin, O as auditTrailPlugin, S as prefixedId, T as cachePlugin, _ as fieldFilterPlugin, a as uniqueField, b as dateSequentialId, c as createTenantContext, d as observabilityPlugin, g as leasePlugin, h as methodRegistryPlugin, i as requireField, k as auditLogPlugin, l as subdocumentPlugin, m as mongoOperationsPlugin, n as blockIf, o as validationChainPlugin, p as multiTenantPlugin, r as immutableField, s as timestampPlugin, t as autoInject, u as softDeletePlugin, v as elasticSearchPlugin, w as cascadePlugin, x as getNextSequence, y as customIdPlugin } from "../validation-chain.plugin-Bbbnq8ay.mjs";
|
|
2
2
|
export { AuditTrailQuery, aggregateHelpersPlugin, auditLogPlugin, auditTrailPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, createTenantContext, customIdPlugin, dateSequentialId, elasticSearchPlugin, fieldFilterPlugin, getNextSequence, immutableField, leasePlugin, methodRegistryPlugin, mongoOperationsPlugin, multiTenantPlugin, observabilityPlugin, prefixedId, requireField, sequentialId, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as upsert } from "./update-C-3viiw1.mjs";
|
|
2
2
|
import { n as warn } from "./logger-DprijP5h.mjs";
|
|
3
3
|
import { t as createError } from "./error-B00pI7dV.mjs";
|
|
4
|
-
import { l as OP_REGISTRY, s as ALL_OPERATIONS, t as HOOK_PRIORITY } from "./Repository-
|
|
4
|
+
import { l as OP_REGISTRY, s as ALL_OPERATIONS, t as HOOK_PRIORITY } from "./Repository-CNBTCVat.mjs";
|
|
5
5
|
import { r as getFieldsForUser } from "./field-selection-Br3WPOEb.mjs";
|
|
6
6
|
import mongoose from "mongoose";
|
|
7
7
|
import { cachePlugin } from "@classytic/repo-core/cache";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/mongokit",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.3",
|
|
4
4
|
"description": "Production-grade MongoDB repositories - smart pagination, events, and plugins. Built on @classytic/repo-core.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
},
|
|
106
106
|
"homepage": "https://github.com/classytic/mongokit#readme",
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"@classytic/repo-core": "
|
|
108
|
+
"@classytic/repo-core": "^0.4.2",
|
|
109
109
|
"better-auth": ">=1.6.0",
|
|
110
110
|
"mongoose": ">=9.4.1"
|
|
111
111
|
},
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"@better-auth/mongo-adapter": "^1.6.9",
|
|
150
150
|
"@biomejs/biome": "^2.4.10",
|
|
151
151
|
"@classytic/dev-tools": "^0.2.0",
|
|
152
|
-
"@classytic/repo-core": "
|
|
152
|
+
"@classytic/repo-core": "0.4.2",
|
|
153
153
|
"@types/node": "^22.0.0",
|
|
154
154
|
"@vitest/coverage-v8": "^3.2.4",
|
|
155
155
|
"ajv": "^8.18.0",
|