326 lines
16 KiB
JavaScript
326 lines
16 KiB
JavaScript
/** Controls when the `EntityManager` flushes pending changes to the database. */
|
|
export var FlushMode;
|
|
(function (FlushMode) {
|
|
/** The `EntityManager` delays the flush until the current Transaction is committed. */
|
|
FlushMode['COMMIT'] = 'commit';
|
|
/** This is the default mode, and it flushes the `EntityManager` only if necessary. */
|
|
FlushMode['AUTO'] = 'auto';
|
|
/** Flushes the `EntityManager` before every query. */
|
|
FlushMode['ALWAYS'] = 'always';
|
|
})(FlushMode || (FlushMode = {}));
|
|
/** Controls how populate hints are resolved when using `FindOptions.populateWhere`. */
|
|
export var PopulateHint;
|
|
(function (PopulateHint) {
|
|
/** Infer population hints from the `where` condition. */
|
|
PopulateHint['INFER'] = 'infer';
|
|
/** Apply population hints to all relations. */
|
|
PopulateHint['ALL'] = 'all';
|
|
})(PopulateHint || (PopulateHint = {}));
|
|
/** Special tokens used as populate path values in `FindOptions.populate`. */
|
|
export var PopulatePath;
|
|
(function (PopulatePath) {
|
|
/** Infer which relations to populate based on fields accessed in the `where` or `orderBy` clause. */
|
|
PopulatePath['INFER'] = '$infer';
|
|
/** Populate all relations. */
|
|
PopulatePath['ALL'] = '*';
|
|
})(PopulatePath || (PopulatePath = {}));
|
|
/** Logical grouping operators for combining query conditions. */
|
|
export var GroupOperator;
|
|
(function (GroupOperator) {
|
|
/** Logical AND — all conditions must match. */
|
|
GroupOperator['$and'] = 'and';
|
|
/** Logical OR — at least one condition must match. */
|
|
GroupOperator['$or'] = 'or';
|
|
})(GroupOperator || (GroupOperator = {}));
|
|
/** Comparison and filtering operators used in query conditions. */
|
|
export var QueryOperator;
|
|
(function (QueryOperator) {
|
|
/** Equal. */
|
|
QueryOperator['$eq'] = '=';
|
|
/** Included in the given list. */
|
|
QueryOperator['$in'] = 'in';
|
|
/** Not included in the given list. */
|
|
QueryOperator['$nin'] = 'not in';
|
|
/** Greater than. */
|
|
QueryOperator['$gt'] = '>';
|
|
/** Greater than or equal to. */
|
|
QueryOperator['$gte'] = '>=';
|
|
/** Less than. */
|
|
QueryOperator['$lt'] = '<';
|
|
/** Less than or equal to. */
|
|
QueryOperator['$lte'] = '<=';
|
|
/** Not equal. */
|
|
QueryOperator['$ne'] = '!=';
|
|
/** Negation wrapper. */
|
|
QueryOperator['$not'] = 'not';
|
|
/** SQL LIKE pattern matching. */
|
|
QueryOperator['$like'] = 'like';
|
|
/** Regular expression matching. */
|
|
QueryOperator['$re'] = 'regexp';
|
|
/** Full-text search. */
|
|
QueryOperator['$fulltext'] = 'fulltext';
|
|
/** Checks that the value is not null (i.e., exists). */
|
|
QueryOperator['$exists'] = 'not null';
|
|
/** Case-insensitive LIKE (PostgreSQL only). */
|
|
QueryOperator['$ilike'] = 'ilike';
|
|
/** Array overlap operator (PostgreSQL only). */
|
|
QueryOperator['$overlap'] = '&&';
|
|
/** Array/JSON contains operator (PostgreSQL only). */
|
|
QueryOperator['$contains'] = '@>';
|
|
/** Array/JSON contained-by operator (PostgreSQL only). */
|
|
QueryOperator['$contained'] = '<@';
|
|
/** No element in the collection matches (SQL only). */
|
|
QueryOperator['$none'] = 'none';
|
|
/** At least one element in the collection matches (SQL only). */
|
|
QueryOperator['$some'] = 'some';
|
|
/** Every element in the collection matches (SQL only). */
|
|
QueryOperator['$every'] = 'every';
|
|
/** Matches collections by their size (SQL only). */
|
|
QueryOperator['$size'] = 'size';
|
|
/** JSON object has the given key (PostgreSQL only). */
|
|
QueryOperator['$hasKey'] = '?';
|
|
/** JSON object has all of the given keys (PostgreSQL only). */
|
|
QueryOperator['$hasKeys'] = '?&';
|
|
/** JSON object has at least one of the given keys (PostgreSQL only). */
|
|
QueryOperator['$hasSomeKeys'] = '?|';
|
|
/** Matches an element inside a JSON array (SQL only). */
|
|
QueryOperator['$elemMatch'] = 'elemMatch';
|
|
})(QueryOperator || (QueryOperator = {}));
|
|
export const ARRAY_OPERATORS = ['$eq', '$gt', '$gte', '$lt', '$lte', '$ne', '$overlap', '$contains', '$contained'];
|
|
export const JSON_KEY_OPERATORS = ['$hasKey', '$hasKeys', '$hasSomeKeys'];
|
|
/** Sort direction for query results. Both upper- and lower-case variants are accepted. */
|
|
export var QueryOrder;
|
|
(function (QueryOrder) {
|
|
/** Ascending order. */
|
|
QueryOrder['ASC'] = 'ASC';
|
|
/** Ascending order with nulls sorted last. */
|
|
QueryOrder['ASC_NULLS_LAST'] = 'ASC NULLS LAST';
|
|
/** Ascending order with nulls sorted first. */
|
|
QueryOrder['ASC_NULLS_FIRST'] = 'ASC NULLS FIRST';
|
|
/** Descending order. */
|
|
QueryOrder['DESC'] = 'DESC';
|
|
/** Descending order with nulls sorted last. */
|
|
QueryOrder['DESC_NULLS_LAST'] = 'DESC NULLS LAST';
|
|
/** Descending order with nulls sorted first. */
|
|
QueryOrder['DESC_NULLS_FIRST'] = 'DESC NULLS FIRST';
|
|
/** Ascending order (lower-case variant). */
|
|
QueryOrder['asc'] = 'asc';
|
|
/** Ascending order with nulls sorted last (lower-case variant). */
|
|
QueryOrder['asc_nulls_last'] = 'asc nulls last';
|
|
/** Ascending order with nulls sorted first (lower-case variant). */
|
|
QueryOrder['asc_nulls_first'] = 'asc nulls first';
|
|
/** Descending order (lower-case variant). */
|
|
QueryOrder['desc'] = 'desc';
|
|
/** Descending order with nulls sorted last (lower-case variant). */
|
|
QueryOrder['desc_nulls_last'] = 'desc nulls last';
|
|
/** Descending order with nulls sorted first (lower-case variant). */
|
|
QueryOrder['desc_nulls_first'] = 'desc nulls first';
|
|
})(QueryOrder || (QueryOrder = {}));
|
|
/** Numeric sort direction, compatible with MongoDB-style ordering. */
|
|
export var QueryOrderNumeric;
|
|
(function (QueryOrderNumeric) {
|
|
/** Ascending order. */
|
|
QueryOrderNumeric[(QueryOrderNumeric['ASC'] = 1)] = 'ASC';
|
|
/** Descending order. */
|
|
QueryOrderNumeric[(QueryOrderNumeric['DESC'] = -1)] = 'DESC';
|
|
})(QueryOrderNumeric || (QueryOrderNumeric = {}));
|
|
/** Flags that modify query builder behavior. */
|
|
export var QueryFlag;
|
|
(function (QueryFlag) {
|
|
/** Add a DISTINCT clause to the SELECT statement. */
|
|
QueryFlag['DISTINCT'] = 'DISTINCT';
|
|
/** Enable result pagination via a sub-query for the primary keys. */
|
|
QueryFlag['PAGINATE'] = 'PAGINATE';
|
|
/** Disable the automatic pagination sub-query. */
|
|
QueryFlag['DISABLE_PAGINATE'] = 'DISABLE_PAGINATE';
|
|
/** Wrap UPDATE statements in a sub-query. */
|
|
QueryFlag['UPDATE_SUB_QUERY'] = 'UPDATE_SUB_QUERY';
|
|
/** Wrap DELETE statements in a sub-query. */
|
|
QueryFlag['DELETE_SUB_QUERY'] = 'DELETE_SUB_QUERY';
|
|
/** Convert values through custom type mappings when reading results. */
|
|
QueryFlag['CONVERT_CUSTOM_TYPES'] = 'CONVERT_CUSTOM_TYPES';
|
|
/** Include lazy formula properties in the SELECT clause. */
|
|
QueryFlag['INCLUDE_LAZY_FORMULAS'] = 'INCLUDE_LAZY_FORMULAS';
|
|
/** Automatically join the owning side of one-to-one relations. */
|
|
QueryFlag['AUTO_JOIN_ONE_TO_ONE_OWNER'] = 'AUTO_JOIN_ONE_TO_ONE_OWNER';
|
|
/** Infer the populate hint from the query fields. */
|
|
QueryFlag['INFER_POPULATE'] = 'INFER_POPULATE';
|
|
/** Prevent nested conditions from being promoted to INNER JOINs. */
|
|
QueryFlag['DISABLE_NESTED_INNER_JOIN'] = 'DISABLE_NESTED_INNER_JOIN';
|
|
/** Enable IDENTITY_INSERT for explicit PK values (MSSQL only). */
|
|
QueryFlag['IDENTITY_INSERT'] = 'IDENTITY_INSERT';
|
|
/** Use an OUTPUT...INTO temp table for returning rows (MSSQL only). */
|
|
QueryFlag['OUTPUT_TABLE'] = 'OUTPUT_TABLE';
|
|
})(QueryFlag || (QueryFlag = {}));
|
|
export const SCALAR_TYPES = new Set([
|
|
'string',
|
|
'number',
|
|
'boolean',
|
|
'bigint',
|
|
'Uint8Array',
|
|
'Date',
|
|
'Buffer',
|
|
'RegExp',
|
|
]);
|
|
/** Describes the kind of relationship a property represents. */
|
|
export var ReferenceKind;
|
|
(function (ReferenceKind) {
|
|
/** A plain scalar property (not a relation). */
|
|
ReferenceKind['SCALAR'] = 'scalar';
|
|
/** A one-to-one relation. */
|
|
ReferenceKind['ONE_TO_ONE'] = '1:1';
|
|
/** A one-to-many relation (inverse side of a many-to-one). */
|
|
ReferenceKind['ONE_TO_MANY'] = '1:m';
|
|
/** A many-to-one relation (owning side). */
|
|
ReferenceKind['MANY_TO_ONE'] = 'm:1';
|
|
/** A many-to-many relation. */
|
|
ReferenceKind['MANY_TO_MANY'] = 'm:n';
|
|
/** An embedded entity (inline object stored within the parent). */
|
|
ReferenceKind['EMBEDDED'] = 'embedded';
|
|
})(ReferenceKind || (ReferenceKind = {}));
|
|
/** Cascade operations that propagate from a parent entity to its relations. */
|
|
export var Cascade;
|
|
(function (Cascade) {
|
|
/** Cascade persist — new related entities are automatically persisted. */
|
|
Cascade['PERSIST'] = 'persist';
|
|
/** Cascade merge — detached related entities are merged into the identity map. */
|
|
Cascade['MERGE'] = 'merge';
|
|
/** Cascade remove — removing the parent also removes related entities. */
|
|
Cascade['REMOVE'] = 'remove';
|
|
/** Enable all cascade operations (persist, merge, remove). */
|
|
Cascade['ALL'] = 'all';
|
|
/** @internal */
|
|
Cascade['SCHEDULE_ORPHAN_REMOVAL'] = 'schedule_orphan_removal';
|
|
/** @internal */
|
|
Cascade['CANCEL_ORPHAN_REMOVAL'] = 'cancel_orphan_removal';
|
|
})(Cascade || (Cascade = {}));
|
|
/** Strategy used to load related entities when populating. */
|
|
export var LoadStrategy;
|
|
(function (LoadStrategy) {
|
|
/** Load relations with a separate SELECT ... WHERE pk IN (...) query. */
|
|
LoadStrategy['SELECT_IN'] = 'select-in';
|
|
/** Load relations via SQL JOINs in a single query. */
|
|
LoadStrategy['JOINED'] = 'joined';
|
|
/** Use joined strategy for to-one relations and select-in for to-many. */
|
|
LoadStrategy['BALANCED'] = 'balanced';
|
|
})(LoadStrategy || (LoadStrategy = {}));
|
|
/** Controls which relation types use the dataloader for batched loading. */
|
|
export var DataloaderType;
|
|
(function (DataloaderType) {
|
|
/** Dataloader is disabled. */
|
|
DataloaderType[(DataloaderType['NONE'] = 0)] = 'NONE';
|
|
/** Use the dataloader for Reference (to-one) relations only. */
|
|
DataloaderType[(DataloaderType['REFERENCE'] = 1)] = 'REFERENCE';
|
|
/** Use the dataloader for Collection (to-many) relations only. */
|
|
DataloaderType[(DataloaderType['COLLECTION'] = 2)] = 'COLLECTION';
|
|
/** Use the dataloader for both Reference and Collection relations. */
|
|
DataloaderType[(DataloaderType['ALL'] = 3)] = 'ALL';
|
|
})(DataloaderType || (DataloaderType = {}));
|
|
/** Locking strategy for concurrency control. */
|
|
export var LockMode;
|
|
(function (LockMode) {
|
|
/** No locking. */
|
|
LockMode[(LockMode['NONE'] = 0)] = 'NONE';
|
|
/** Optimistic locking via a version column. */
|
|
LockMode[(LockMode['OPTIMISTIC'] = 1)] = 'OPTIMISTIC';
|
|
/** Pessimistic shared lock (FOR SHARE). */
|
|
LockMode[(LockMode['PESSIMISTIC_READ'] = 2)] = 'PESSIMISTIC_READ';
|
|
/** Pessimistic exclusive lock (FOR UPDATE). */
|
|
LockMode[(LockMode['PESSIMISTIC_WRITE'] = 3)] = 'PESSIMISTIC_WRITE';
|
|
/** Pessimistic exclusive lock that skips already-locked rows (FOR UPDATE SKIP LOCKED). */
|
|
LockMode[(LockMode['PESSIMISTIC_PARTIAL_WRITE'] = 4)] = 'PESSIMISTIC_PARTIAL_WRITE';
|
|
/** Pessimistic exclusive lock that fails immediately if the row is locked (FOR UPDATE NOWAIT). */
|
|
LockMode[(LockMode['PESSIMISTIC_WRITE_OR_FAIL'] = 5)] = 'PESSIMISTIC_WRITE_OR_FAIL';
|
|
/** Pessimistic shared lock that skips already-locked rows (FOR SHARE SKIP LOCKED). */
|
|
LockMode[(LockMode['PESSIMISTIC_PARTIAL_READ'] = 6)] = 'PESSIMISTIC_PARTIAL_READ';
|
|
/** Pessimistic shared lock that fails immediately if the row is locked (FOR SHARE NOWAIT). */
|
|
LockMode[(LockMode['PESSIMISTIC_READ_OR_FAIL'] = 7)] = 'PESSIMISTIC_READ_OR_FAIL';
|
|
})(LockMode || (LockMode = {}));
|
|
/** Transaction isolation levels as defined by the SQL standard (plus vendor extensions). */
|
|
export var IsolationLevel;
|
|
(function (IsolationLevel) {
|
|
/** Allows dirty reads, non-repeatable reads, and phantom reads. */
|
|
IsolationLevel['READ_UNCOMMITTED'] = 'read uncommitted';
|
|
/** Prevents dirty reads; non-repeatable and phantom reads are still possible. */
|
|
IsolationLevel['READ_COMMITTED'] = 'read committed';
|
|
/** Snapshot isolation — each transaction sees a consistent snapshot of the database (MSSQL). */
|
|
IsolationLevel['SNAPSHOT'] = 'snapshot';
|
|
/** Prevents dirty and non-repeatable reads; phantom reads are still possible. */
|
|
IsolationLevel['REPEATABLE_READ'] = 'repeatable read';
|
|
/** Full isolation — transactions are executed as if they were run sequentially. */
|
|
IsolationLevel['SERIALIZABLE'] = 'serializable';
|
|
})(IsolationLevel || (IsolationLevel = {}));
|
|
/** Lifecycle and transaction events emitted by the ORM. */
|
|
export var EventType;
|
|
(function (EventType) {
|
|
/** Fired when an entity instance is created (via constructor or `em.create`). */
|
|
EventType['onInit'] = 'onInit';
|
|
/** Fired after an entity is loaded from the database. */
|
|
EventType['onLoad'] = 'onLoad';
|
|
/** Fired before a new entity is inserted into the database. */
|
|
EventType['beforeCreate'] = 'beforeCreate';
|
|
/** Fired after a new entity has been inserted into the database. */
|
|
EventType['afterCreate'] = 'afterCreate';
|
|
/** Fired before an existing entity is updated in the database. */
|
|
EventType['beforeUpdate'] = 'beforeUpdate';
|
|
/** Fired after an existing entity has been updated in the database. */
|
|
EventType['afterUpdate'] = 'afterUpdate';
|
|
/** Fired before an upsert operation. */
|
|
EventType['beforeUpsert'] = 'beforeUpsert';
|
|
/** Fired after an upsert operation. */
|
|
EventType['afterUpsert'] = 'afterUpsert';
|
|
/** Fired before an entity is deleted from the database. */
|
|
EventType['beforeDelete'] = 'beforeDelete';
|
|
/** Fired after an entity has been deleted from the database. */
|
|
EventType['afterDelete'] = 'afterDelete';
|
|
/** Fired at the very beginning of `em.flush()`, before change detection. */
|
|
EventType['beforeFlush'] = 'beforeFlush';
|
|
/** Fired during `em.flush()` after change detection but before database writes. */
|
|
EventType['onFlush'] = 'onFlush';
|
|
/** Fired after `em.flush()` has completed all database writes. */
|
|
EventType['afterFlush'] = 'afterFlush';
|
|
/** Fired before a new database transaction is started. */
|
|
EventType['beforeTransactionStart'] = 'beforeTransactionStart';
|
|
/** Fired after a new database transaction has been started. */
|
|
EventType['afterTransactionStart'] = 'afterTransactionStart';
|
|
/** Fired before a database transaction is committed. */
|
|
EventType['beforeTransactionCommit'] = 'beforeTransactionCommit';
|
|
/** Fired after a database transaction has been committed. */
|
|
EventType['afterTransactionCommit'] = 'afterTransactionCommit';
|
|
/** Fired before a database transaction is rolled back. */
|
|
EventType['beforeTransactionRollback'] = 'beforeTransactionRollback';
|
|
/** Fired after a database transaction has been rolled back. */
|
|
EventType['afterTransactionRollback'] = 'afterTransactionRollback';
|
|
})(EventType || (EventType = {}));
|
|
export const EventTypeMap = Object.keys(EventType).reduce((a, b, i) => {
|
|
a[b] = i;
|
|
return a;
|
|
}, {});
|
|
/** Controls how a transactional operation interacts with an existing transaction. */
|
|
export var TransactionPropagation;
|
|
(function (TransactionPropagation) {
|
|
/** Join the current transaction or create a new one if none exists. */
|
|
TransactionPropagation['REQUIRED'] = 'required';
|
|
/** Always create a new transaction, suspending the current one if it exists. */
|
|
TransactionPropagation['REQUIRES_NEW'] = 'requires_new';
|
|
/** Create a nested savepoint within the current transaction, or a new transaction if none exists. */
|
|
TransactionPropagation['NESTED'] = 'nested';
|
|
/** Execute non-transactionally, suspending the current transaction if one exists. */
|
|
TransactionPropagation['NOT_SUPPORTED'] = 'not_supported';
|
|
/** Join the current transaction if one exists, otherwise execute non-transactionally. */
|
|
TransactionPropagation['SUPPORTS'] = 'supports';
|
|
/** Join the current transaction; throw if no transaction is active. */
|
|
TransactionPropagation['MANDATORY'] = 'mandatory';
|
|
/** Execute non-transactionally; throw if a transaction is active. */
|
|
TransactionPropagation['NEVER'] = 'never';
|
|
})(TransactionPropagation || (TransactionPropagation = {}));
|
|
export class PlainObject {}
|
|
/** Constraint deferral mode for database constraints (e.g., foreign keys, unique). */
|
|
export var DeferMode;
|
|
(function (DeferMode) {
|
|
/** The constraint is checked immediately by default, but can be deferred within a transaction. */
|
|
DeferMode['INITIALLY_IMMEDIATE'] = 'immediate';
|
|
/** The constraint is deferred until the transaction is committed. */
|
|
DeferMode['INITIALLY_DEFERRED'] = 'deferred';
|
|
})(DeferMode || (DeferMode = {}));
|