Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@mikro-orm/core

Package Overview
Dependencies
Maintainers
1
Versions
4513
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mikro-orm/core - npm Package Compare versions

Comparing version
7.1.0-dev.31
to
7.1.0-dev.32
+29
-0
connections/Connection.d.ts

@@ -107,1 +107,30 @@ import { type Configuration, type ConnectionOptions } from '../utils/Configuration.js';

export type Transaction<T = any> = T & {};
/**
* Strategy applied when an `AbortSignal` fires while a query is in flight.
*
* - `'ignore query'` — stop awaiting; the query keeps running on the server until it settles
* (the connection returns to the pool only when the database replies).
* - `'cancel query'` — ask the database to cancel the running query (e.g. `pg_cancel_backend`,
* `KILL QUERY`). Falls back to `'ignore query'` if the dialect cannot cancel.
* Most engines do not cancel writes; partial commits are possible.
* - `'kill session'` — terminate the database session/process the query runs in
* (`pg_terminate_backend` etc.). Falls back to `'cancel query'` if not supported.
*
* Default: `'ignore query'`.
*
* **Streaming queries (`em.stream()` / `qb.stream()`):** the strategy is silently treated as
* `'ignore query'` because the underlying driver only accepts a plain `AbortSignal` for
* streamed reads — there is no server-side cancel for an open cursor. The MongoDB driver also
* has no notion of strategies; only the signal is honored there.
*/
export type InflightQueryAbortStrategy = 'ignore query' | 'cancel query' | 'kill session';
/** Per-query cancellation controls forwarded to the underlying driver. */
export interface AbortQueryOptions {
/** AbortSignal that cancels the query when fired. */
signal?: AbortSignal;
/**
* Strategy used when the signal fires while the query is in flight. See
* {@apilink InflightQueryAbortStrategy} for caveats around streams and MongoDB.
*/
inflightQueryAbortStrategy?: InflightQueryAbortStrategy;
}
+6
-6
import type { ConnectionType, Constructor, EntityData, EntityMetadata, EntityProperty, FilterQuery, Primary, Dictionary, IPrimaryKey, PopulateOptions, EntityDictionary, AutoPath, ObjectQuery, FilterObject, Populate, EntityName, PopulateHintOptions, Prefixes, IndexName } from '../typings.js';
import type { Connection, QueryResult, Transaction } from '../connections/Connection.js';
import type { AbortQueryOptions, Connection, QueryResult, Transaction } from '../connections/Connection.js';
import type { FlushMode, LockMode, QueryOrderMap, QueryFlag, LoadStrategy, PopulateHint, PopulatePath } from '../enums.js';

@@ -147,3 +147,3 @@ import type { Platform } from '../platforms/Platform.js';

/** Options for `em.find()` queries, including population, ordering, pagination, and locking. */
export interface FindOptions<Entity, Hint extends string = never, Fields extends string = never, Excludes extends string = never> extends LoadHint<Entity, Hint, Fields, Excludes> {
export interface FindOptions<Entity, Hint extends string = never, Fields extends string = never, Excludes extends string = never> extends LoadHint<Entity, Hint, Fields, Excludes>, AbortQueryOptions {
/**

@@ -278,3 +278,3 @@ * Where condition for populated relations. This will have no effect on the root entity.

/** Options for native insert and update operations. */
export interface NativeInsertUpdateOptions<T> {
export interface NativeInsertUpdateOptions<T> extends AbortQueryOptions {
convertCustomTypes?: boolean;

@@ -313,3 +313,3 @@ ctx?: Transaction;

/** Options for `em.count()` queries. */
export interface CountOptions<T extends object, P extends string = never> {
export interface CountOptions<T extends object, P extends string = never> extends AbortQueryOptions {
filters?: FilterOptions;

@@ -356,3 +356,3 @@ schema?: string;

/** Options for `em.qb().update()` operations. */
export interface UpdateOptions<T> {
export interface UpdateOptions<T> extends AbortQueryOptions {
filters?: FilterOptions;

@@ -396,3 +396,3 @@ schema?: string;

/** Base options shared by all driver methods (transaction context, schema, logging). */
export interface DriverMethodOptions {
export interface DriverMethodOptions extends AbortQueryOptions {
ctx?: Transaction;

@@ -399,0 +399,0 @@ schema?: string;

import type { AnyEntity, AutoPath, ConnectionType, EntityName, EntityProperty, FilterQuery, PopulateHintOptions, PopulateOptions } from '../typings.js';
import type { EntityManager } from '../EntityManager.js';
import { LoadStrategy, type LockMode, type PopulateHint, PopulatePath, type QueryOrderMap } from '../enums.js';
import type { InflightQueryAbortStrategy } from '../connections/Connection.js';
import type { FilterOptions } from '../drivers/IDatabaseDriver.js';

@@ -42,2 +43,6 @@ import type { LoggingOptions } from '../logging/Logger.js';

populateHints?: Record<string, PopulateHintOptions>;
/** AbortSignal forwarded to populated relation queries. */
signal?: AbortSignal;
/** Cancellation strategy paired with {@link signal}. */
inflightQueryAbortStrategy?: InflightQueryAbortStrategy;
}

@@ -44,0 +49,0 @@ /** Responsible for batch-loading entity relations using either select-in or joined loading strategies. */

@@ -396,2 +396,4 @@ import { QueryHelper } from '../utils/QueryHelper.js';

connectionType,
signal: options.signal,
inflightQueryAbortStrategy: options.inflightQueryAbortStrategy,
// @ts-ignore not a public option, will be propagated to the populate call

@@ -398,0 +400,0 @@ refresh: refresh && !children.every(item => options.visited.has(item)),

@@ -13,3 +13,3 @@ import { type Configuration } from './utils/Configuration.js';

import type { MetadataStorage } from './metadata/MetadataStorage.js';
import type { Transaction } from './connections/Connection.js';
import type { AbortQueryOptions, InflightQueryAbortStrategy, Transaction } from './connections/Connection.js';
import { EventManager } from './events/EventManager.js';

@@ -37,2 +37,6 @@ import type { EntityComparator } from './utils/EntityComparator.js';

protected loggerContext?: Dictionary;
/** @internal */
protected signal?: AbortSignal;
/** @internal */
protected inflightQueryAbortStrategy?: InflightQueryAbortStrategy;
/**

@@ -538,2 +542,9 @@ * @internal

/**
* Returns the cancellation defaults configured on this EntityManager (via `em.fork({ signal })`
* or inherited from a transactional fork). Returns `undefined` when no signal is set.
*
* @internal — exposed for subclass drivers and `UnitOfWork`; not part of the public API.
*/
protected getAbortOptions(): AbortQueryOptions | undefined;
/**
* Sets the transaction context.

@@ -572,3 +583,3 @@ */

protected shouldRefresh<T extends object, P extends string = never, F extends string = never, E extends string = never>(meta: EntityMetadata<T>, entity: T, options: FindOneOptions<T, P, F, E>): boolean;
protected prepareOptions(options: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any> | CountByOptions<any>): void;
protected prepareOptions(options: (FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any> | CountOptions<any, any> | CountByOptions<any>) & AbortQueryOptions): void;
/**

@@ -668,2 +679,9 @@ * @internal

loggerContext?: Dictionary;
/**
* Default `AbortSignal` applied to every operation on this fork (queries and UoW flushes).
* Per-call options.signal still takes precedence.
*/
signal?: AbortSignal;
/** Default cancellation strategy paired with {@link signal}. */
inflightQueryAbortStrategy?: InflightQueryAbortStrategy;
}
import type { EntityKey, ExpandProperty } from './typings.js';
import type { Transaction } from './connections/Connection.js';
import type { InflightQueryAbortStrategy, Transaction } from './connections/Connection.js';
import type { LogContext } from './logging/Logger.js';

@@ -310,2 +310,9 @@ /** Controls when the `EntityManager` flushes pending changes to the database. */

loggerContext?: LogContext;
/**
* `AbortSignal` cancelling every query within the transaction (including the implicit flush).
* Cancelling mid-transaction triggers a rollback once the in-flight query settles.
*/
signal?: AbortSignal;
/** Cancellation strategy paired with {@link signal}. */
inflightQueryAbortStrategy?: InflightQueryAbortStrategy;
}

@@ -312,0 +319,0 @@ export declare abstract class PlainObject {

{
"name": "@mikro-orm/core",
"version": "7.1.0-dev.31",
"version": "7.1.0-dev.32",
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -39,2 +39,9 @@ import { Collection } from '../entity/Collection.js';

#em;
/**
* UoW lives in `@mikro-orm/core` alongside `EntityManager` and reaches `getAbortOptions`
* (TS-protected) via cast — TS has no `friend` keyword, so this is the documented escape hatch.
*/
get #abortOptions() {
return this.#em.getAbortOptions();
}
constructor(em) {

@@ -1006,3 +1013,3 @@ this.#em = em;

}
await this.#changeSetPersister.executeInserts(changeSets, { ctx });
await this.#changeSetPersister.executeInserts(changeSets, { ctx, ...this.#abortOptions });
for (const changeSet of changeSets) {

@@ -1076,3 +1083,3 @@ // For TPT entities, use the full entity snapshot instead of the partial changeset payload,

}
await this.#changeSetPersister.executeUpdates(changeSets, batched, { ctx });
await this.#changeSetPersister.executeUpdates(changeSets, batched, { ctx, ...this.#abortOptions });
for (const changeSet of changeSets) {

@@ -1100,3 +1107,3 @@ const wrapped = helper(changeSet.entity);

}
await this.#changeSetPersister.executeDeletes(changeSets, { ctx });
await this.#changeSetPersister.executeDeletes(changeSets, { ctx, ...this.#abortOptions });
for (const changeSet of changeSets) {

@@ -1139,2 +1146,3 @@ this.unsetIdentity(changeSet.entity);

loggerContext,
...this.#abortOptions,
});

@@ -1141,0 +1149,0 @@ for (const coll of this.#collectionUpdates) {

@@ -139,2 +139,4 @@ import { ReferenceKind, TransactionPropagation } from '../enums.js';

loggerContext: options.loggerContext,
signal: options.signal,
inflightQueryAbortStrategy: options.inflightQueryAbortStrategy,
});

@@ -141,0 +143,0 @@ }

@@ -144,3 +144,3 @@ import { clone } from './clone.js';

static PK_SEPARATOR = '~~~';
static #ORM_VERSION = '7.1.0-dev.31';
static #ORM_VERSION = '7.1.0-dev.32';
/**

@@ -147,0 +147,0 @@ * Checks if the argument is instance of `Object`. Returns false for arrays.

Sorry, the diff of this file is too big to display