🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@mikro-orm/core

Package Overview
Dependencies
Maintainers
1
Versions
4705
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.11-dev.1
to
7.1.11-dev.2
+6
-4
cache/CacheAdapter.d.ts
/** Interface for async-capable cache storage used by result cache and metadata cache. */
export interface CacheAdapter {
/**
* Gets the items under `name` key from the cache.
* Gets the items under `name` key from the cache. When `origin` is provided, adapters that
* track the entry origin should ignore entries cached from a different source file.
*/
get<T = any>(name: string): T | Promise<T | undefined> | undefined;
get<T = any>(name: string, origin?: string): T | Promise<T | undefined> | undefined;
/**

@@ -27,5 +28,6 @@ * Sets the item to the cache. `origin` is used for cache invalidation and should reflect the change in data.

/**
* Gets the items under `name` key from the cache.
* Gets the items under `name` key from the cache. When `origin` is provided, adapters that
* track the entry origin should ignore entries cached from a different source file.
*/
get<T = any>(name: string): T | undefined;
get<T = any>(name: string, origin?: string): T | undefined;
/**

@@ -32,0 +34,0 @@ * Sets the item to the cache. `origin` is used for cache invalidation and should reflect the change in data.

+1
-1

@@ -11,3 +11,3 @@ import type { SyncCacheAdapter } from './CacheAdapter.js';

*/
get(name: string): any;
get(name: string, origin?: string): any;
/**

@@ -14,0 +14,0 @@ * @inheritDoc

@@ -19,3 +19,3 @@ import { existsSync, readFileSync, writeFileSync, unlinkSync } from 'node:fs';

*/
get(name) {
get(name, origin) {
const path = this.path(name);

@@ -26,2 +26,7 @@ if (!existsSync(path)) {

const payload = fs.readJSONSync(path);
// Two classes with the same name share the cache key, ignore entries cached
// from a different source file.
if (origin && fs.absolutePath(payload.origin, this.#baseDir) !== fs.absolutePath(origin, this.#baseDir)) {
return null;
}
const hash = this.getHash(payload.origin);

@@ -28,0 +33,0 @@ if (!hash || payload.hash !== hash) {

@@ -7,2 +7,4 @@ import { EntityMetadata, } from '../typings.js';

import { EnumArrayType } from '../types/EnumArrayType.js';
// mirrors `MetadataStorage.META_SYMBOL`, we can't import it here due to a module cycle
const META_SYMBOL = Symbol.for('@mikro-orm/core/MetadataStorage.META_SYMBOL');
/** Class-less entity definition that provides a programmatic API for defining entities without decorators. */

@@ -224,4 +226,5 @@ export class EntitySchema {

// and registers their custom class via setClass, we don't want to discover the
// auto-generated class as a separate parent entity.
if (base !== BaseEntity && base.name !== this._meta.className) {
// auto-generated class as a separate parent entity. A parent carrying its own decorator
// metadata is a real base class even when a minifier mangles it to the same name as the child.
if (base !== BaseEntity && (base.name !== this._meta.className || Object.hasOwn(base, META_SYMBOL))) {
this._meta.extends ??= base.name ? base : undefined;

@@ -228,0 +231,0 @@ }

@@ -95,3 +95,3 @@ import { Utils } from '../utils/Utils.js';

}
const cache = meta.path && this.config.getMetadataCacheAdapter().get(this.getCacheKey(meta));
const cache = meta.path && this.config.getMetadataCacheAdapter().get(this.getCacheKey(meta), meta.path);
if (cache) {

@@ -98,0 +98,0 @@ this.loadFromCache(meta, cache);

@@ -1,2 +0,2 @@

import { type Dictionary, EntityMetadata, type EntityName } from '../typings.js';
import { type Dictionary, type EntityCtor, EntityMetadata, type EntityName } from '../typings.js';
import type { EntityManager } from '../EntityManager.js';

@@ -7,6 +7,7 @@ /** Registry that stores and provides access to entity metadata by class, name, or id. */

static readonly PATH_SYMBOL: unique symbol;
static readonly META_SYMBOL: unique symbol;
constructor(metadata?: Dictionary<EntityMetadata>);
/** Returns the global metadata dictionary, or a specific entry by entity name and path. */
/** Returns the global metadata dictionary, or a specific entry by entity name and path (keyed by the class reference when `target` is provided). */
static getMetadata(): Dictionary<EntityMetadata>;
static getMetadata<T = any>(entity: string, path: string): EntityMetadata<T>;
static getMetadata<T = any>(entity: string, path: string, target?: EntityCtor): EntityMetadata<T>;
/** Checks whether an entity with the given class name exists in the global metadata. */

@@ -13,0 +14,0 @@ static isKnownEntity(name: string): boolean;

@@ -14,2 +14,3 @@ import { EntityMetadata } from '../typings.js';

static PATH_SYMBOL = Symbol.for('@mikro-orm/core/MetadataStorage.PATH_SYMBOL');
static META_SYMBOL = Symbol.for('@mikro-orm/core/MetadataStorage.META_SYMBOL');
static #metadata = getGlobalStorage('metadata');

@@ -30,4 +31,17 @@ #metadataMap = new Map();

}
static getMetadata(entity, path) {
static getMetadata(entity, path, target) {
const key = entity && path ? entity + '-' + Utils.hash(path) : null;
// Key the registry by the class reference when available, so two classes minified
// to the same mangled name don't collide on the `className-path` key.
if (key && target) {
if (!Object.hasOwn(target, MetadataStorage.META_SYMBOL)) {
Object.defineProperty(target, MetadataStorage.META_SYMBOL, {
value: new EntityMetadata({ className: entity, path }),
writable: true,
});
}
// Keep the name-keyed entry in sync, the class-keyed metadata survives `MetadataStorage.clear()`.
MetadataStorage.#metadata[key] = target[MetadataStorage.META_SYMBOL];
return target[MetadataStorage.META_SYMBOL];
}
if (key && !MetadataStorage.#metadata[key]) {

@@ -34,0 +48,0 @@ MetadataStorage.#metadata[key] = new EntityMetadata({ className: entity, path });

{
"name": "@mikro-orm/core",
"version": "7.1.11-dev.1",
"version": "7.1.11-dev.2",
"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": [

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

static PK_SEPARATOR = '~~~';
static #ORM_VERSION = '7.1.11-dev.1';
static #ORM_VERSION = '7.1.11-dev.2';
/**

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

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