@classytic/mongokit 3.0.5 → 3.0.6
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/actions/index.d.ts +2 -2
- package/dist/{index-BljuCDFC.d.ts → index-CkwbNdpJ.d.ts} +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +25 -4
- package/dist/pagination/PaginationEngine.d.ts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/{queryParser-CxzCjzXd.d.ts → queryParser-Do3SgsyJ.d.ts} +1 -1
- package/dist/{types-CHIDluaP.d.ts → types-DDDYo18H.d.ts} +8 -1
- package/dist/utils/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/actions/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { a as aggregate, c as create, _ as deleteActions, r as read, u as update } from '../index-
|
|
1
|
+
export { a as aggregate, c as create, _ as deleteActions, r as read, u as update } from '../index-CkwbNdpJ.js';
|
|
2
2
|
import 'mongoose';
|
|
3
|
-
import '../types-
|
|
3
|
+
import '../types-DDDYo18H.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Model, ClientSession, PipelineStage } from 'mongoose';
|
|
2
|
-
import { A as AnyDocument, C as CreateOptions, h as ObjectId, n as OperationOptions, S as SelectSpec, e as PopulateSpec, f as SortSpec, U as UpdateOptions, p as UpdateWithValidationResult, o as UpdateManyResult, D as DeleteResult,
|
|
2
|
+
import { A as AnyDocument, C as CreateOptions, h as ObjectId, n as OperationOptions, S as SelectSpec, e as PopulateSpec, f as SortSpec, U as UpdateOptions, p as UpdateWithValidationResult, o as UpdateManyResult, D as DeleteResult, X as GroupResult, T as LookupOptions, Y as MinMaxResult } from './types-DDDYo18H.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Create Actions
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { A as AnyDocument, g as PluginType, P as PaginationConfig, R as RepositoryOptions, h as ObjectId, S as SelectSpec, e as PopulateSpec, f as SortSpec, a as OffsetPaginationResult, b as KeysetPaginationResult, U as UpdateOptions, d as AggregatePaginationResult, i as RepositoryContext, H as HttpError } from './types-
|
|
2
|
-
export { c as AggregatePaginationOptions, j as AnyModel,
|
|
1
|
+
import { A as AnyDocument, g as PluginType, P as PaginationConfig, R as RepositoryOptions, h as ObjectId, S as SelectSpec, e as PopulateSpec, f as SortSpec, a as OffsetPaginationResult, b as KeysetPaginationResult, U as UpdateOptions, d as AggregatePaginationResult, W as WithTransactionOptions, i as RepositoryContext, H as HttpError } from './types-DDDYo18H.js';
|
|
2
|
+
export { c as AggregatePaginationOptions, j as AnyModel, Z as CacheAdapter, $ as CacheOperationOptions, _ as CacheOptions, a0 as CacheStats, a2 as CascadeOptions, a1 as CascadeRelation, C as CreateOptions, z as CrudSchemas, B as DecodedCursor, D as DeleteResult, E as EventPayload, F as FieldPreset, x as FieldRules, w as FilterQuery, X as GroupResult, l as HookMode, J as JsonSchema, K as KeysetPaginationOptions, L as Logger, T as LookupOptions, Y as MinMaxResult, O as OffsetPaginationOptions, n as OperationOptions, m as PaginationResult, v as ParsedQuery, r as Plugin, s as PluginFunction, u as RepositoryEvent, t as RepositoryInstance, y as SchemaBuilderOptions, N as SoftDeleteFilterMode, M as SoftDeleteOptions, Q as SoftDeleteRepository, k as SortDirection, o as UpdateManyResult, p as UpdateWithValidationResult, q as UserContext, I as ValidationChainOptions, V as ValidationResult, G as ValidatorDefinition } from './types-DDDYo18H.js';
|
|
3
3
|
import * as mongoose from 'mongoose';
|
|
4
4
|
import { Model, ClientSession, PipelineStage, PopulateOptions } from 'mongoose';
|
|
5
5
|
import { PaginationEngine } from './pagination/PaginationEngine.js';
|
|
6
6
|
export { aggregateHelpersPlugin, auditLogPlugin, autoInject, batchOperationsPlugin, blockIf, cachePlugin, cascadePlugin, fieldFilterPlugin, immutableField, methodRegistryPlugin, mongoOperationsPlugin, requireField, softDeletePlugin, subdocumentPlugin, timestampPlugin, uniqueField, validationChainPlugin } from './plugins/index.js';
|
|
7
|
-
export { F as FilterValue, O as OperatorMap, Q as QueryParser, b as QueryParserOptions, h as buildCrudSchemasFromModel, e as buildCrudSchemasFromMongooseSchema, l as createError, c as createFieldPreset, m as createMemoryCache, f as filterResponseData, g as getFieldsForUser, i as getImmutableFields, a as getMongooseProjection, j as getSystemManagedFields, k as isFieldUpdateAllowed, d as queryParser, v as validateUpdateBody } from './queryParser-
|
|
8
|
-
export { i as actions } from './index-
|
|
7
|
+
export { F as FilterValue, O as OperatorMap, Q as QueryParser, b as QueryParserOptions, h as buildCrudSchemasFromModel, e as buildCrudSchemasFromMongooseSchema, l as createError, c as createFieldPreset, m as createMemoryCache, f as filterResponseData, g as getFieldsForUser, i as getImmutableFields, a as getMongooseProjection, j as getSystemManagedFields, k as isFieldUpdateAllowed, d as queryParser, v as validateUpdateBody } from './queryParser-Do3SgsyJ.js';
|
|
8
|
+
export { i as actions } from './index-CkwbNdpJ.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Repository Pattern - Data Access Layer
|
|
@@ -203,7 +203,8 @@ declare class Repository<TDoc = AnyDocument> {
|
|
|
203
203
|
/**
|
|
204
204
|
* Execute callback within a transaction
|
|
205
205
|
*/
|
|
206
|
-
withTransaction<T>(callback: (session: ClientSession) => Promise<T
|
|
206
|
+
withTransaction<T>(callback: (session: ClientSession | null) => Promise<T>, options?: WithTransactionOptions): Promise<T>;
|
|
207
|
+
private _isTransactionUnsupported;
|
|
207
208
|
/**
|
|
208
209
|
* Execute custom query with event emission
|
|
209
210
|
*/
|
|
@@ -238,4 +239,4 @@ declare class Repository<TDoc = AnyDocument> {
|
|
|
238
239
|
*/
|
|
239
240
|
declare function createRepository<TDoc>(Model: mongoose.Model<TDoc, any, any, any>, plugins?: PluginType[], paginationConfig?: PaginationConfig, options?: RepositoryOptions): Repository<TDoc>;
|
|
240
241
|
|
|
241
|
-
export { AggregatePaginationResult, AnyDocument, HttpError, KeysetPaginationResult, ObjectId, OffsetPaginationResult, PaginationConfig, PaginationEngine, PluginType, PopulateSpec, Repository, RepositoryContext, RepositoryOptions, SelectSpec, SortSpec, UpdateOptions, createRepository, Repository as default };
|
|
242
|
+
export { AggregatePaginationResult, AnyDocument, HttpError, KeysetPaginationResult, ObjectId, OffsetPaginationResult, PaginationConfig, PaginationEngine, PluginType, PopulateSpec, Repository, RepositoryContext, RepositoryOptions, SelectSpec, SortSpec, UpdateOptions, WithTransactionOptions, createRepository, Repository as default };
|
package/dist/index.js
CHANGED
|
@@ -1108,20 +1108,41 @@ var Repository = class {
|
|
|
1108
1108
|
/**
|
|
1109
1109
|
* Execute callback within a transaction
|
|
1110
1110
|
*/
|
|
1111
|
-
async withTransaction(callback) {
|
|
1111
|
+
async withTransaction(callback, options = {}) {
|
|
1112
1112
|
const session = await mongoose4.startSession();
|
|
1113
|
-
|
|
1113
|
+
let started = false;
|
|
1114
1114
|
try {
|
|
1115
|
+
session.startTransaction();
|
|
1116
|
+
started = true;
|
|
1115
1117
|
const result = await callback(session);
|
|
1116
1118
|
await session.commitTransaction();
|
|
1117
1119
|
return result;
|
|
1118
1120
|
} catch (error) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
+
const err = error;
|
|
1122
|
+
if (options.allowFallback && this._isTransactionUnsupported(err)) {
|
|
1123
|
+
if (typeof options.onFallback === "function") {
|
|
1124
|
+
options.onFallback(err);
|
|
1125
|
+
}
|
|
1126
|
+
if (started && session.inTransaction()) {
|
|
1127
|
+
try {
|
|
1128
|
+
await session.abortTransaction();
|
|
1129
|
+
} catch {
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
return await callback(null);
|
|
1133
|
+
}
|
|
1134
|
+
if (started && session.inTransaction()) {
|
|
1135
|
+
await session.abortTransaction();
|
|
1136
|
+
}
|
|
1137
|
+
throw err;
|
|
1121
1138
|
} finally {
|
|
1122
1139
|
session.endSession();
|
|
1123
1140
|
}
|
|
1124
1141
|
}
|
|
1142
|
+
_isTransactionUnsupported(error) {
|
|
1143
|
+
const message = (error.message || "").toLowerCase();
|
|
1144
|
+
return message.includes("transaction numbers are only allowed on a replica set member") || message.includes("replica set") || message.includes("mongos");
|
|
1145
|
+
}
|
|
1125
1146
|
/**
|
|
1126
1147
|
* Execute custom query with event emission
|
|
1127
1148
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Model } from 'mongoose';
|
|
2
|
-
import { A as AnyDocument, P as PaginationConfig, O as OffsetPaginationOptions, a as OffsetPaginationResult, K as KeysetPaginationOptions, b as KeysetPaginationResult, c as AggregatePaginationOptions, d as AggregatePaginationResult } from '../types-
|
|
2
|
+
import { A as AnyDocument, P as PaginationConfig, O as OffsetPaginationOptions, a as OffsetPaginationResult, K as KeysetPaginationOptions, b as KeysetPaginationResult, c as AggregatePaginationOptions, d as AggregatePaginationResult } from '../types-DDDYo18H.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Pagination Engine
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FieldPreset, r as Plugin, L as Logger, M as SoftDeleteOptions, t as RepositoryInstance, G as ValidatorDefinition, I as ValidationChainOptions, i as RepositoryContext,
|
|
1
|
+
import { F as FieldPreset, r as Plugin, L as Logger, M as SoftDeleteOptions, t as RepositoryInstance, G as ValidatorDefinition, I as ValidationChainOptions, i as RepositoryContext, _ as CacheOptions, a2 as CascadeOptions } from '../types-DDDYo18H.js';
|
|
2
2
|
import 'mongoose';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as UserContext, F as FieldPreset, H as HttpError,
|
|
1
|
+
import { q as UserContext, F as FieldPreset, H as HttpError, Z as CacheAdapter, y as SchemaBuilderOptions, z as CrudSchemas, V as ValidationResult, v as ParsedQuery } from './types-DDDYo18H.js';
|
|
2
2
|
import mongoose__default, { Schema } from 'mongoose';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -158,6 +158,13 @@ interface OperationOptions {
|
|
|
158
158
|
/** Additional query filters (e.g., for soft delete) */
|
|
159
159
|
query?: Record<string, unknown>;
|
|
160
160
|
}
|
|
161
|
+
/** withTransaction options */
|
|
162
|
+
interface WithTransactionOptions {
|
|
163
|
+
/** Allow non-transactional fallback when transactions are unsupported */
|
|
164
|
+
allowFallback?: boolean;
|
|
165
|
+
/** Optional hook to observe fallback triggers */
|
|
166
|
+
onFallback?: (error: Error) => void;
|
|
167
|
+
}
|
|
161
168
|
/** Create operation options */
|
|
162
169
|
interface CreateOptions {
|
|
163
170
|
/** MongoDB session for transactions */
|
|
@@ -566,4 +573,4 @@ interface HttpError extends Error {
|
|
|
566
573
|
}>;
|
|
567
574
|
}
|
|
568
575
|
|
|
569
|
-
export type {
|
|
576
|
+
export type { CacheOperationOptions as $, AnyDocument as A, DecodedCursor as B, CreateOptions as C, DeleteResult as D, EventPayload as E, FieldPreset as F, ValidatorDefinition as G, HttpError as H, ValidationChainOptions as I, JsonSchema as J, KeysetPaginationOptions as K, Logger as L, SoftDeleteOptions as M, SoftDeleteFilterMode as N, OffsetPaginationOptions as O, PaginationConfig as P, SoftDeleteRepository as Q, RepositoryOptions as R, SelectSpec as S, LookupOptions as T, UpdateOptions as U, ValidationResult as V, WithTransactionOptions as W, GroupResult as X, MinMaxResult as Y, CacheAdapter as Z, CacheOptions as _, OffsetPaginationResult as a, CacheStats as a0, CascadeRelation as a1, CascadeOptions as a2, KeysetPaginationResult as b, AggregatePaginationOptions as c, AggregatePaginationResult as d, PopulateSpec as e, SortSpec as f, PluginType as g, ObjectId as h, RepositoryContext as i, AnyModel as j, SortDirection as k, HookMode as l, PaginationResult as m, OperationOptions as n, UpdateManyResult as o, UpdateWithValidationResult as p, UserContext as q, Plugin as r, PluginFunction as s, RepositoryInstance as t, RepositoryEvent as u, ParsedQuery as v, FilterQuery as w, FieldRules as x, SchemaBuilderOptions as y, CrudSchemas as z };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { F as FilterValue, O as OperatorMap, Q as QueryParser, b as QueryParserOptions, h as buildCrudSchemasFromModel, e as buildCrudSchemasFromMongooseSchema, l as createError, c as createFieldPreset, m as createMemoryCache, f as filterResponseData, g as getFieldsForUser, i as getImmutableFields, a as getMongooseProjection, j as getSystemManagedFields, k as isFieldUpdateAllowed, d as queryParser, v as validateUpdateBody } from '../queryParser-
|
|
2
|
-
import { S as SelectSpec, e as PopulateSpec, f as SortSpec } from '../types-
|
|
1
|
+
export { F as FilterValue, O as OperatorMap, Q as QueryParser, b as QueryParserOptions, h as buildCrudSchemasFromModel, e as buildCrudSchemasFromMongooseSchema, l as createError, c as createFieldPreset, m as createMemoryCache, f as filterResponseData, g as getFieldsForUser, i as getImmutableFields, a as getMongooseProjection, j as getSystemManagedFields, k as isFieldUpdateAllowed, d as queryParser, v as validateUpdateBody } from '../queryParser-Do3SgsyJ.js';
|
|
2
|
+
import { S as SelectSpec, e as PopulateSpec, f as SortSpec } from '../types-DDDYo18H.js';
|
|
3
3
|
import 'mongoose';
|
|
4
4
|
|
|
5
5
|
/**
|
package/package.json
CHANGED