typeorm
Version:
Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, WebSQL, MongoDB databases.
1,078 lines (1,042 loc) • 2 MB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [0, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
System.register("typeorm/driver/types/ColumnTypes", [], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
return {
setters: [],
execute: function () {
// "string"|"text"|"number"|"integer"|"int"|"smallint"|"bigint"|"float"|"double"|
// "decimal"|"date"|"time"|"datetime"|"boolean"|"json"|"jsonb"|"simple_array"|"uuid";
// -------------------------------------------------------------------------
// Merged Types
// -------------------------------------------------------------------------
/*
/!**
* Column types where column length is used.
*!/
export type WithLengthColumnType =
VarcharColumnType|
CharColumnType|
IntervalColumnType|
BitColumnType|
VarbitColumnType;
/!**
* Column types where time options are used.
*!/
export type WithTimeColumnType =
TimeColumnType|
TimestampColumnType;
/!**
* All other column types without extra options used.
*!/
export type SimpleColumnType =
SmallintColumnType|
IntegerColumnType|
BigintColumnType|
DecimalColumnType|
RealColumnType|
DoublePrecisionColumnType|
SmallserialColumnType|
SerialColumnType|
BigserialColumnType|
MoneyColumnType|
TextColumnType|
ByteaColumnType|
DateColumnType|
BooleanColumnType|
PointColumnType|
LineColumnType|
LsegColumnType|
BoxColumnType|
CircleColumnType|
PathColumnType|
PolygonColumnType|
CidrColumnType|
InetColumnType|
MacaddrColumnType|
TsvectorColumnType|
TsqueryColumnType|
UUIDColumnType|
XmlColumnType|
JsonColumnType|
JsonbColumnType;
/!**
* All column types supported by a database.
*!/
export type AllColumnType =
SimpleColumnType|
WithLengthColumnType|
WithTimeColumnType|
NumericColumnType|
EnumColumnType;
/!**
* All data types that column can be.
*!/
export type ColumnType =
"tinyint"|
"smallint"|
"int2"|
"mediumint"|
"integer"|
"int"|
"int4"|
"bigint"|
"int8"|
"decimal"|
"numeric"|
"real"|
"float4"|
"float"|
"double"|
"double precision"|
"numeric"|
"decimal"|
"string"|"text"|"number"|"integer"|"int"|"smallint"|"bigint"|"float"|"double"|
"decimal"|"date"|"time"|"datetime"|"boolean"|"json"|"jsonb"|"simple_array"|"uuid";*/
/*
/!**
* All data types that column can be.
*!/
export class ColumnTypes {
/!**
* SQL VARCHAR type. Your class's property type should be a "string".
*!/
static STRING: ColumnType = "string";
/!**
* SQL CLOB type. Your class's property type should be a "string".
*!/
static TEXT: ColumnType = "text";
/!**
* SQL FLOAT type. Your class's property type should be a "number".
*!/
static NUMBER: ColumnType = "number";
/!**
* SQL INT type. Your class's property type should be a "number".
*!/
static INTEGER: ColumnType = "integer";
/!**
* SQL INT type. Your class's property type should be a "number".
*!/
static INT: ColumnType = "int";
/!**
* SQL SMALLINT type. Your class's property type should be a "number".
*!/
static SMALLINT: ColumnType = "smallint";
/!**
* SQL BIGINT type. Your class's property type should be a "number".
*!/
static BIGINT: ColumnType = "bigint";
/!**
* SQL FLOAT type. Your class's property type should be a "number".
*!/
static FLOAT: ColumnType = "float";
/!**
* SQL FLOAT type. Your class's property type should be a "number".
*!/
static DOUBLE: ColumnType = "double";
/!**
* SQL DECIMAL type. Your class's property type should be a "string".
*!/
static DECIMAL: ColumnType = "decimal";
/!**
* SQL DATETIME type. Your class's property type should be a "Date" object.
*!/
static DATE: ColumnType = "date";
/!**
* SQL TIME type. Your class's property type should be a "Date" object.
*!/
static TIME: ColumnType = "time";
/!**
* SQL DATETIME/TIMESTAMP type. Your class's property type should be a "Date" object.
*!/
static DATETIME: ColumnType = "datetime";
/!**
* SQL BOOLEAN type. Your class's property type should be a "boolean".
*!/
static BOOLEAN: ColumnType = "boolean";
/!**
* SQL CLOB type. Your class's property type should be any Object.
*!/
static JSON: ColumnType = "json";
/!**
* Postgres jsonb type. Your class's property type should be any Object.
*!/
static JSONB: ColumnType = "jsonb";
/!**
* SQL CLOB type. Your class's property type should be array of string. Note: value in this column should not contain
* a comma (",") since this symbol is used to create a string from the array, using .join(",") operator.
*!/
static SIMPLE_ARRAY: ColumnType = "simple_array";
/!**
* UUID type. Serialized to a string in typescript or javascript
*!/
static UUID: ColumnType = "uuid";
/!**
* Checks if given type in a string format is supported by ORM.
*!/
static isTypeSupported(type: string) {
return this.supportedTypes.indexOf(<ColumnType> type) !== -1;
}
/!**
* Returns list of all supported types by the ORM.
*!/
static get supportedTypes() {
return [
this.STRING,
this.TEXT,
this.NUMBER,
this.INTEGER,
this.INT,
this.SMALLINT,
this.BIGINT,
this.FLOAT,
this.DOUBLE,
this.DECIMAL,
this.DATE,
this.TIME,
this.DATETIME,
this.BOOLEAN,
this.JSON,
this.JSONB,
this.SIMPLE_ARRAY,
this.UUID
];
}
/!**
* Tries to guess a column type from the given function.
*!/
static determineTypeFromFunction(type: Function): ColumnType|undefined {
if (type instanceof Date) {
return ColumnTypes.DATETIME;
} else if (type instanceof Function) {
const typeName = (<any>type).name.toLowerCase();
switch (typeName) {
case "number":
return ColumnTypes.NUMBER;
case "boolean":
return ColumnTypes.BOOLEAN;
case "string":
return ColumnTypes.STRING;
case "date":
return ColumnTypes.DATETIME;
case "object":
return ColumnTypes.JSON;
}
} else if (type instanceof Object) {
return ColumnTypes.JSON;
}
return undefined;
}
static typeToString(type: Function): string {
return (type as any).name.toLowerCase();
}
/!**
* Checks if column type is numeric.
*!/
static isNumeric(type: ColumnType) {
return type === ColumnTypes.NUMBER ||
type === ColumnTypes.INT ||
type === ColumnTypes.INTEGER ||
type === ColumnTypes.BIGINT ||
type === ColumnTypes.SMALLINT ||
type === ColumnTypes.DOUBLE ||
type === ColumnTypes.FLOAT;
}
}*/
}
};
});
System.register("typeorm/metadata/types/RelationTypes", [], function (exports_2, context_2) {
"use strict";
var __moduleName = context_2 && context_2.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/naming-strategy/NamingStrategyInterface", [], function (exports_3, context_3) {
"use strict";
var __moduleName = context_3 && context_3.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/metadata/types/OnDeleteType", [], function (exports_4, context_4) {
"use strict";
var __moduleName = context_4 && context_4.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/metadata/ForeignKeyMetadata", [], function (exports_5, context_5) {
"use strict";
var __moduleName = context_5 && context_5.id;
var ForeignKeyMetadata;
return {
setters: [],
execute: function () {
/**
* Contains all information about entity's foreign key.
*/
ForeignKeyMetadata = /** @class */ (function () {
// ---------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------
function ForeignKeyMetadata(options) {
/**
* Array of columns of this foreign key.
*/
this.columns = [];
/**
* Array of referenced columns.
*/
this.referencedColumns = [];
/**
* Gets array of column names.
*/
this.columnNames = [];
/**
* Gets array of referenced column names.
*/
this.referencedColumnNames = [];
this.entityMetadata = options.entityMetadata;
this.referencedEntityMetadata = options.referencedEntityMetadata;
this.columns = options.columns;
this.referencedColumns = options.referencedColumns;
this.onDelete = options.onDelete;
if (options.namingStrategy)
this.build(options.namingStrategy);
}
// ---------------------------------------------------------------------
// Public Methods
// ---------------------------------------------------------------------
/**
* Builds some depend foreign key properties.
* Must be called after all entity metadatas and their columns are built.
*/
ForeignKeyMetadata.prototype.build = function (namingStrategy) {
this.columnNames = this.columns.map(function (column) { return column.databaseName; });
this.referencedColumnNames = this.referencedColumns.map(function (column) { return column.databaseName; });
this.tableName = this.entityMetadata.tableName;
this.referencedTableName = this.referencedEntityMetadata.tableName;
this.name = namingStrategy.foreignKeyName(this.tableName, this.columnNames, this.referencedEntityMetadata.tableName, this.referencedColumnNames);
};
return ForeignKeyMetadata;
}());
exports_5("ForeignKeyMetadata", ForeignKeyMetadata);
}
};
});
System.register("typeorm/common/ObjectLiteral", [], function (exports_6, context_6) {
"use strict";
var __moduleName = context_6 && context_6.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/metadata-args/EmbeddedMetadataArgs", [], function (exports_7, context_7) {
"use strict";
var __moduleName = context_7 && context_7.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/query-builder/QueryBuilderUtils", [], function (exports_8, context_8) {
"use strict";
var __moduleName = context_8 && context_8.id;
var QueryBuilderUtils;
return {
setters: [],
execute: function () {
/**
* Helper utility functions for QueryBuilder.
*/
QueryBuilderUtils = /** @class */ (function () {
function QueryBuilderUtils() {
}
/**
* Checks if given value is a string representation of alias property,
* e.g. "post.category" or "post.id".
*/
QueryBuilderUtils.isAliasProperty = function (str) {
// alias property must be a string and must have a dot separator
if (typeof str !== "string" || str.indexOf(".") === -1)
return false;
// extra alias and its property relation
var _a = str.split("."), aliasName = _a[0], propertyName = _a[1]; // todo: what about relations in embedded?
if (!aliasName || !propertyName)
return false;
// alias and property must be represented in a special format
var aliasNameRegexp = /^[a-zA-Z0-9_-]+$/;
if (!aliasNameRegexp.test(aliasName) || !aliasNameRegexp.test(propertyName))
return false;
return true;
};
return QueryBuilderUtils;
}());
exports_8("QueryBuilderUtils", QueryBuilderUtils);
}
};
});
System.register("typeorm/query-builder/Alias", [], function (exports_9, context_9) {
"use strict";
var __moduleName = context_9 && context_9.id;
var Alias;
return {
setters: [],
execute: function () {
/**
*/
Alias = /** @class */ (function () {
function Alias(alias) {
Object.assign(this, alias || {});
}
Object.defineProperty(Alias.prototype, "target", {
get: function () {
return this.metadata.target;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Alias.prototype, "hasMetadata", {
get: function () {
return !!this._metadata;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Alias.prototype, "metadata", {
get: function () {
if (!this._metadata)
throw new Error("Cannot get entity metadata for the given alias \"" + this.name + "\"");
return this._metadata;
},
set: function (metadata) {
this._metadata = metadata;
},
enumerable: true,
configurable: true
});
return Alias;
}());
exports_9("Alias", Alias);
}
};
});
System.register("typeorm/find-options/OrderByCondition", [], function (exports_10, context_10) {
"use strict";
var __moduleName = context_10 && context_10.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/query-builder/JoinAttribute", ["typeorm/query-builder/QueryBuilderUtils"], function (exports_11, context_11) {
"use strict";
var __moduleName = context_11 && context_11.id;
var QueryBuilderUtils_1, JoinAttribute;
return {
setters: [
function (QueryBuilderUtils_1_1) {
QueryBuilderUtils_1 = QueryBuilderUtils_1_1;
}
],
execute: function () {
/**
* Stores all join attributes which will be used to build a JOIN query.
*/
JoinAttribute = /** @class */ (function () {
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
function JoinAttribute(connection, queryExpressionMap, joinAttribute) {
this.connection = connection;
this.queryExpressionMap = queryExpressionMap;
Object.assign(this, joinAttribute || {});
}
Object.defineProperty(JoinAttribute.prototype, "isMany", {
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
get: function () {
if (this.isMappingMany !== undefined)
return this.isMappingMany;
if (this.relation)
return this.relation.isManyToMany || this.relation.isOneToMany;
return false;
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "tablePath", {
/**
* Name of the table which we should join.
*/
get: function () {
return this.metadata ? this.metadata.tablePath : this.entityOrProperty;
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "parentAlias", {
/**
* Alias of the parent of this join.
* For example, if we join ("post.category", "categoryAlias") then "post" is a parent alias.
* This value is extracted from entityOrProperty value.
* This is available when join was made using "post.category" syntax.
*/
get: function () {
if (!QueryBuilderUtils_1.QueryBuilderUtils.isAliasProperty(this.entityOrProperty))
return undefined;
return this.entityOrProperty.substr(0, this.entityOrProperty.indexOf("."));
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "relationPropertyPath", {
/**
* Relation property name of the parent.
* This is used to understand what is joined.
* For example, if we join ("post.category", "categoryAlias") then "category" is a relation property.
* This value is extracted from entityOrProperty value.
* This is available when join was made using "post.category" syntax.
*/
get: function () {
if (!QueryBuilderUtils_1.QueryBuilderUtils.isAliasProperty(this.entityOrProperty))
return undefined;
return this.entityOrProperty.substr(this.entityOrProperty.indexOf(".") + 1);
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "relation", {
/**
* Relation of the parent.
* This is used to understand what is joined.
* This is available when join was made using "post.category" syntax.
* Relation can be undefined if entityOrProperty is regular entity or custom table.
*/
get: function () {
if (!QueryBuilderUtils_1.QueryBuilderUtils.isAliasProperty(this.entityOrProperty))
return undefined;
var relationOwnerSelection = this.queryExpressionMap.findAliasByName(this.parentAlias);
var relation = relationOwnerSelection.metadata.findRelationWithPropertyPath(this.relationPropertyPath);
if (relation) {
return relation;
}
if (relationOwnerSelection.metadata.parentEntityMetadata) {
relation = relationOwnerSelection.metadata.parentEntityMetadata.findRelationWithPropertyPath(this.relationPropertyPath);
if (relation) {
return relation;
}
}
throw new Error("Relation with property path " + this.relationPropertyPath + " in entity was not found.");
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "metadata", {
/**
* Metadata of the joined entity.
* If table without entity was joined, then it will return undefined.
*/
get: function () {
// entityOrProperty is relation, e.g. "post.category"
if (this.relation)
return this.relation.inverseEntityMetadata;
// entityOrProperty is Entity class
if (this.connection.hasMetadata(this.entityOrProperty))
return this.connection.getMetadata(this.entityOrProperty);
return undefined;
/*if (typeof this.entityOrProperty === "string") { // entityOrProperty is a custom table
// first try to find entity with such name, this is needed when entity does not have a target class,
// and its target is a string name (scenario when plain old javascript is used or entity schema is loaded from files)
const metadata = this.connection.entityMetadatas.find(metadata => metadata.name === this.entityOrProperty);
if (metadata)
return metadata;
// check if we have entity with such table name, and use its metadata if found
return this.connection.entityMetadatas.find(metadata => metadata.tableName === this.entityOrProperty);
}*/
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "junctionAlias", {
/**
* Generates alias of junction table, whose ids we get.
*/
get: function () {
if (!this.relation)
throw new Error("Cannot get junction table for join without relation.");
return this.relation.isOwning ? this.parentAlias + "_" + this.alias.name : this.alias.name + "_" + this.parentAlias;
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "mapToPropertyParentAlias", {
get: function () {
if (!this.mapToProperty)
return undefined;
return this.mapToProperty.split(".")[0];
},
enumerable: true,
configurable: true
});
Object.defineProperty(JoinAttribute.prototype, "mapToPropertyPropertyName", {
get: function () {
if (!this.mapToProperty)
return undefined;
return this.mapToProperty.split(".")[1];
},
enumerable: true,
configurable: true
});
return JoinAttribute;
}());
exports_11("JoinAttribute", JoinAttribute);
}
};
});
System.register("typeorm/query-builder/relation-count/RelationCountAttribute", ["typeorm/query-builder/QueryBuilderUtils"], function (exports_12, context_12) {
"use strict";
var __moduleName = context_12 && context_12.id;
var QueryBuilderUtils_2, RelationCountAttribute;
return {
setters: [
function (QueryBuilderUtils_2_1) {
QueryBuilderUtils_2 = QueryBuilderUtils_2_1;
}
],
execute: function () {
RelationCountAttribute = /** @class */ (function () {
// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------
function RelationCountAttribute(expressionMap, relationCountAttribute) {
this.expressionMap = expressionMap;
Object.assign(this, relationCountAttribute || {});
}
Object.defineProperty(RelationCountAttribute.prototype, "joinInverseSideMetadata", {
// -------------------------------------------------------------------------
// Public Methods
// -------------------------------------------------------------------------
get: function () {
return this.relation.inverseEntityMetadata;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "parentAlias", {
/**
* Alias of the parent of this join.
* For example, if we join ("post.category", "categoryAlias") then "post" is a parent alias.
* This value is extracted from entityOrProperty value.
* This is available when join was made using "post.category" syntax.
*/
get: function () {
if (!QueryBuilderUtils_2.QueryBuilderUtils.isAliasProperty(this.relationName))
throw new Error("Given value must be a string representation of alias property");
return this.relationName.split(".")[0];
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "relationProperty", {
/**
* Relation property name of the parent.
* This is used to understand what is joined.
* For example, if we join ("post.category", "categoryAlias") then "category" is a relation property.
* This value is extracted from entityOrProperty value.
* This is available when join was made using "post.category" syntax.
*/
get: function () {
if (!QueryBuilderUtils_2.QueryBuilderUtils.isAliasProperty(this.relationName))
throw new Error("Given value is a string representation of alias property");
return this.relationName.split(".")[1];
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "junctionAlias", {
get: function () {
var _a = this.relationName.split("."), parentAlias = _a[0], relationProperty = _a[1];
return parentAlias + "_" + relationProperty + "_relation_count";
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "relation", {
/**
* Relation of the parent.
* This is used to understand what is joined.
* This is available when join was made using "post.category" syntax.
*/
get: function () {
if (!QueryBuilderUtils_2.QueryBuilderUtils.isAliasProperty(this.relationName))
throw new Error("Given value is a string representation of alias property");
var _a = this.relationName.split("."), parentAlias = _a[0], propertyPath = _a[1];
var relationOwnerSelection = this.expressionMap.findAliasByName(parentAlias);
var relation = relationOwnerSelection.metadata.findRelationWithPropertyPath(propertyPath);
if (!relation)
throw new Error("Relation with property path " + propertyPath + " in entity was not found.");
return relation;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "metadata", {
/**
* Metadata of the joined entity.
* If table without entity was joined, then it will return undefined.
*/
get: function () {
if (!QueryBuilderUtils_2.QueryBuilderUtils.isAliasProperty(this.relationName))
throw new Error("Given value is a string representation of alias property");
var parentAlias = this.relationName.split(".")[0];
var selection = this.expressionMap.findAliasByName(parentAlias);
return selection.metadata;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RelationCountAttribute.prototype, "mapToPropertyPropertyName", {
get: function () {
return this.mapToProperty.split(".")[1];
},
enumerable: true,
configurable: true
});
return RelationCountAttribute;
}());
exports_12("RelationCountAttribute", RelationCountAttribute);
}
};
});
System.register("typeorm/query-builder/SelectQuery", [], function (exports_13, context_13) {
"use strict";
var __moduleName = context_13 && context_13.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/error/ConnectionIsNotSetError", [], function (exports_14, context_14) {
"use strict";
var __moduleName = context_14 && context_14.id;
var ConnectionIsNotSetError;
return {
setters: [],
execute: function () {
/**
* Thrown when user tries to execute operation that requires connection to be established.
*/
ConnectionIsNotSetError = /** @class */ (function (_super) {
__extends(ConnectionIsNotSetError, _super);
function ConnectionIsNotSetError(dbType) {
var _this = _super.call(this) || this;
_this.name = "ConnectionIsNotSetError";
_this.message = "Connection with " + dbType + " database is not established. Check connection configuration.";
return _this;
}
return ConnectionIsNotSetError;
}(Error));
exports_14("ConnectionIsNotSetError", ConnectionIsNotSetError);
}
};
});
System.register("typeorm/error/DriverPackageNotInstalledError", [], function (exports_15, context_15) {
"use strict";
var __moduleName = context_15 && context_15.id;
var DriverPackageNotInstalledError;
return {
setters: [],
execute: function () {
/**
* Thrown when required driver's package is not installed.
*/
DriverPackageNotInstalledError = /** @class */ (function (_super) {
__extends(DriverPackageNotInstalledError, _super);
function DriverPackageNotInstalledError(driverName, packageName) {
var _this = _super.call(this) || this;
_this.name = "DriverPackageNotInstalledError";
_this.message = driverName + " package has not been found installed. Try to install it: npm install " + packageName + " --save";
return _this;
}
return DriverPackageNotInstalledError;
}(Error));
exports_15("DriverPackageNotInstalledError", DriverPackageNotInstalledError);
}
};
});
System.register("typeorm/driver/DriverUtils", [], function (exports_16, context_16) {
"use strict";
var __moduleName = context_16 && context_16.id;
var DriverUtils;
return {
setters: [],
execute: function () {
/**
* Common driver utility functions.
*/
DriverUtils = /** @class */ (function () {
function DriverUtils() {
}
// -------------------------------------------------------------------------
// Public Static Methods
// -------------------------------------------------------------------------
/**
* Normalizes and builds a new driver options.
* Extracts settings from connection url and sets to a new options object.
*/
DriverUtils.buildDriverOptions = function (options, buildOptions) {
if (options.url) {
var parsedUrl = this.parseConnectionUrl(options.url);
if (buildOptions && buildOptions.useSid) {
var urlDriverOptions = {
type: options.type,
host: parsedUrl.host,
username: parsedUrl.username,
password: parsedUrl.password,
port: parsedUrl.port,
sid: parsedUrl.database
};
return Object.assign(urlDriverOptions, options);
}
else {
var urlDriverOptions = {
type: options.type,
host: parsedUrl.host,
username: parsedUrl.username,
password: parsedUrl.password,
port: parsedUrl.port,
database: parsedUrl.database
};
return Object.assign(urlDriverOptions, options);
}
}
return Object.assign({}, options);
};
// -------------------------------------------------------------------------
// Private Static Methods
// -------------------------------------------------------------------------
/**
* Extracts connection data from the connection url.
*/
DriverUtils.parseConnectionUrl = function (url) {
var firstSlashes = url.indexOf("//");
var preBase = url.substr(firstSlashes + 2);
var secondSlash = preBase.indexOf("/");
var base = (secondSlash !== -1) ? preBase.substr(0, secondSlash) : preBase;
var afterBase = (secondSlash !== -1) ? preBase.substr(secondSlash + 1) : undefined;
var _a = base.split("@"), usernameAndPassword = _a[0], hostAndPort = _a[1];
var _b = usernameAndPassword.split(":"), username = _b[0], password = _b[1];
var _c = hostAndPort.split(":"), host = _c[0], port = _c[1];
return {
host: host,
username: username,
password: password,
port: port ? parseInt(port) : undefined,
database: afterBase || undefined
};
};
return DriverUtils;
}());
exports_16("DriverUtils", DriverUtils);
}
};
});
System.register("typeorm/error/TransactionAlreadyStartedError", [], function (exports_17, context_17) {
"use strict";
var __moduleName = context_17 && context_17.id;
var TransactionAlreadyStartedError;
return {
setters: [],
execute: function () {
/**
* Thrown when transaction is already started and user tries to run it again.
*/
TransactionAlreadyStartedError = /** @class */ (function (_super) {
__extends(TransactionAlreadyStartedError, _super);
function TransactionAlreadyStartedError() {
var _this = _super.call(this) || this;
_this.name = "TransactionAlreadyStartedError";
_this.message = "Transaction already started for the given connection, commit current transaction before starting a new one.";
return _this;
}
return TransactionAlreadyStartedError;
}(Error));
exports_17("TransactionAlreadyStartedError", TransactionAlreadyStartedError);
}
};
});
System.register("typeorm/error/TransactionNotStartedError", [], function (exports_18, context_18) {
"use strict";
var __moduleName = context_18 && context_18.id;
var TransactionNotStartedError;
return {
setters: [],
execute: function () {
/**
* Thrown when transaction is not started yet and user tries to run commit or rollback.
*/
TransactionNotStartedError = /** @class */ (function (_super) {
__extends(TransactionNotStartedError, _super);
function TransactionNotStartedError() {
var _this = _super.call(this) || this;
_this.name = "TransactionNotStartedError";
_this.message = "Transaction is not started yet, start transaction before committing or rolling it back.";
return _this;
}
return TransactionNotStartedError;
}(Error));
exports_18("TransactionNotStartedError", TransactionNotStartedError);
}
};
});
System.register("typeorm/metadata-args/IndexMetadataArgs", [], function (exports_19, context_19) {
"use strict";
var __moduleName = context_19 && context_19.id;
return {
setters: [],
execute: function () {
}
};
});
System.register("typeorm/metadata/IndexMetadata", [], function (exports_20, context_20) {
"use strict";
var __moduleName = context_20 && context_20.id;
var IndexMetadata;
return {
setters: [],
execute: function () {
/**
* Index metadata contains all information about table's index.
*/
IndexMetadata = /** @class */ (function () {
// ---------------------------------------------------------------------
// Constructor
// ---------------------------------------------------------------------
function IndexMetadata(options) {
/**
* Indicates if this index must be unique.
*/
this.isUnique = false;
/**
* Indexed columns.
*/
this.columns = [];
/**
* Map of column names with order set.
* Used only by MongoDB driver.
*/
this.columnNamesWithOrderingMap = {};
this.entityMetadata = options.entityMetadata;
this.embeddedMetadata = options.embeddedMetadata;
if (options.columns)
this.columns = options.columns;
if (options.args) {
this.target = options.args.target;
this.isUnique = options.args.unique;
this.isSparse = options.args.sparse;
this.givenName = options.args.name;
this.givenColumnNames = options.args.columns;
}
}
// ---------------------------------------------------------------------
// Public Build Methods
// ---------------------------------------------------------------------
/**
* Builds some depend index properties.
* Must be called after all entity metadata's properties map, columns and relations are built.
*/
IndexMetadata.prototype.build = function (namingStrategy) {
var _this = this;
var map = {};
this.tableName = this.entityMetadata.tableName;
// if columns already an array of string then simply return it
if (this.givenColumnNames) {
var columnPropertyPaths = [];
if (this.givenColumnNames instanceof Array) {
columnPropertyPaths = this.givenColumnNames.map(function (columnName) {
if (_this.embeddedMetadata)
return _this.embeddedMetadata.propertyPath + "." + columnName;
return columnName;
});
columnPropertyPaths.forEach(function (propertyPath) { return map[propertyPath] = 1; });
}
else {
// if columns is a function that returns array of field names then execute it and get columns names from it
var columnsFnResult_1 = this.givenColumnNames(this.entityMetadata.propertiesMap);
if (columnsFnResult_1 instanceof Array) {
columnPropertyPaths = columnsFnResult_1.map(function (i) { return String(i); });
columnPropertyPaths.forEach(function (name) { return map[name] = 1; });
}
else {
columnPropertyPaths = Object.keys(columnsFnResult_1).map(function (i) { return String(i); });
Object.keys(columnsFnResult_1).forEach(function (columnName) { return map[columnName] = columnsFnResult_1[columnName]; });
}
}
this.