typeorm 0.2.43-dev.60a5b84 → 0.2.43-dev.96aed8a

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.
Files changed (46) hide show
  1. package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  2. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.d.ts +18 -0
  3. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.js +8 -0
  4. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -0
  5. package/browser/entity-schema/EntitySchemaEmbeddedError.d.ts +6 -0
  6. package/browser/entity-schema/EntitySchemaEmbeddedError.js +18 -0
  7. package/browser/entity-schema/EntitySchemaEmbeddedError.js.map +1 -0
  8. package/browser/entity-schema/EntitySchemaOptions.d.ts +7 -1
  9. package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
  10. package/browser/entity-schema/EntitySchemaTransformer.d.ts +1 -0
  11. package/browser/entity-schema/EntitySchemaTransformer.js +217 -191
  12. package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
  13. package/browser/index.d.ts +1 -0
  14. package/browser/index.js +1 -0
  15. package/browser/index.js.map +1 -1
  16. package/browser/metadata/EmbeddedMetadata.d.ts +1 -1
  17. package/browser/metadata/EmbeddedMetadata.js +3 -0
  18. package/browser/metadata/EmbeddedMetadata.js.map +1 -1
  19. package/browser/metadata-args/EmbeddedMetadataArgs.d.ts +2 -2
  20. package/browser/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
  21. package/browser/metadata-builder/EntityMetadataBuilder.js +3 -1
  22. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  23. package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  24. package/entity-schema/EntitySchemaEmbeddedColumnOptions.d.ts +18 -0
  25. package/entity-schema/EntitySchemaEmbeddedColumnOptions.js +11 -0
  26. package/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -0
  27. package/entity-schema/EntitySchemaEmbeddedError.d.ts +6 -0
  28. package/entity-schema/EntitySchemaEmbeddedError.js +21 -0
  29. package/entity-schema/EntitySchemaEmbeddedError.js.map +1 -0
  30. package/entity-schema/EntitySchemaOptions.d.ts +7 -1
  31. package/entity-schema/EntitySchemaOptions.js.map +1 -1
  32. package/entity-schema/EntitySchemaTransformer.d.ts +1 -0
  33. package/entity-schema/EntitySchemaTransformer.js +217 -191
  34. package/entity-schema/EntitySchemaTransformer.js.map +1 -1
  35. package/index.d.ts +1 -0
  36. package/index.js +3 -1
  37. package/index.js.map +1 -1
  38. package/index.mjs +2 -0
  39. package/metadata/EmbeddedMetadata.d.ts +1 -1
  40. package/metadata/EmbeddedMetadata.js +3 -0
  41. package/metadata/EmbeddedMetadata.js.map +1 -1
  42. package/metadata-args/EmbeddedMetadataArgs.d.ts +2 -2
  43. package/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
  44. package/metadata-builder/EntityMetadataBuilder.js +3 -1
  45. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  46. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaColumnOptions.ts"],"names":[],"mappings":"","file":"EntitySchemaColumnOptions.js","sourcesContent":["import {ColumnType} from \"../driver/types/ColumnTypes\";\nimport {ValueTransformer} from \"../decorator/options/ValueTransformer\";\nimport {SpatialColumnOptions} from \"../decorator/options/SpatialColumnOptions\";\n\nexport interface EntitySchemaColumnOptions extends SpatialColumnOptions {\n\n /**\n * Indicates if this column is a primary column.\n */\n primary?: boolean;\n\n /**\n * Indicates if this column is of type ObjectID\n */\n objectId?: boolean;\n\n /**\n * Indicates if this column is a created date column.\n */\n createDate?: boolean;\n\n /**\n * Indicates if this column is an update date column.\n */\n updateDate?: boolean;\n\n /**\n * Indicates if this column is a delete date column.\n */\n deleteDate?: boolean;\n\n /**\n * Indicates if this column is a version column.\n */\n version?: boolean;\n\n /**\n * Indicates if this column is a treeChildrenCount column.\n */\n treeChildrenCount?: boolean;\n\n /**\n * Indicates if this column is a treeLevel column.\n */\n treeLevel?: boolean;\n\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type: ColumnType;\n\n /**\n * Column name in the database.\n */\n name?: string;\n\n /**\n * Column type's length. For example type = \"string\" and length = 100 means that ORM will create a column with\n * type varchar(100).\n */\n length?: string | number;\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Indicates if column's value can be set to NULL.\n */\n nullable?: boolean;\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean;\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean;\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean;\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean;\n\n /**\n * Specifies if this column will use AUTO_INCREMENT or not (e.g. generated number).\n */\n generated?: true|\"increment\"|\"uuid\"|\"rowid\";\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean;\n\n /**\n * Extra column definition. Should be used only in emergency situations. Note that if you'll use this property\n * auto schema generation will not work properly anymore. Avoid using it.\n */\n columnDefinition?: string;\n\n /**\n * Column comment.\n */\n comment?: string;\n\n /**\n * Default database value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean;\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string;\n\n /**\n * Defines a column collation.\n */\n collation?: string;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: any[]|Object;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\"|\"string\";\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean;\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer|ValueTransformer[];\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaColumnOptions.ts"],"names":[],"mappings":"","file":"EntitySchemaColumnOptions.js","sourcesContent":["import {ColumnType} from \"../driver/types/ColumnTypes\";\nimport {ValueTransformer} from \"../decorator/options/ValueTransformer\";\nimport {SpatialColumnOptions} from \"../decorator/options/SpatialColumnOptions\";\n\nexport interface EntitySchemaColumnOptions extends SpatialColumnOptions {\n\n /**\n * Indicates if this column is a primary column.\n */\n primary?: boolean;\n\n /**\n * Indicates if this column is of type ObjectID\n */\n objectId?: boolean;\n\n /**\n * Indicates if this column is a created date column.\n */\n createDate?: boolean;\n\n /**\n * Indicates if this column is an update date column.\n */\n updateDate?: boolean;\n\n /**\n * Indicates if this column is a delete date column.\n */\n deleteDate?: boolean;\n\n /**\n * Indicates if this column is a version column.\n */\n version?: boolean;\n\n /**\n * Indicates if this column is a treeChildrenCount column.\n */\n treeChildrenCount?: boolean;\n\n /**\n * Indicates if this column is a treeLevel column.\n */\n treeLevel?: boolean;\n\n /**\n * Column type. Must be one of the value from the ColumnTypes class.\n */\n type: ColumnType;\n\n /**\n * Column name in the database.\n */\n name?: string;\n\n /**\n * Column type's length. For example type = \"string\" and length = 100 means that ORM will create a column with\n * type varchar(100).\n */\n length?: string | number;\n\n /**\n * Column type's display width. Used only on some column types in MySQL.\n * For example, INT(4) specifies an INT with a display width of four digits.\n */\n width?: number;\n\n /**\n * Indicates if column's value can be set to NULL.\n */\n nullable?: boolean;\n\n /**\n * Indicates if column value is not updated by \"save\" operation.\n * It means you'll be able to write this value only when you first time insert the object.\n * Default value is \"false\".\n *\n * @deprecated Please use the `update` option instead. Careful, it takes\n * the opposite value to readonly.\n *\n */\n readonly?: boolean;\n\n /**\n * Indicates if column value is updated by \"save\" operation.\n * If false you'll be able to write this value only when you first time insert the object.\n * Default value is \"true\".\n */\n update?: boolean;\n\n /**\n * Indicates if column is always selected by QueryBuilder and find operations.\n * Default value is \"true\".\n */\n select?: boolean;\n\n /**\n * Indicates if column is inserted by default.\n * Default value is \"true\".\n */\n insert?: boolean;\n\n /**\n * Specifies if this column will use AUTO_INCREMENT or not (e.g. generated number).\n */\n generated?: true|\"increment\"|\"uuid\"|\"rowid\";\n\n /**\n * Specifies if column's value must be unique or not.\n */\n unique?: boolean;\n\n /**\n * Extra column definition. Should be used only in emergency situations. Note that if you'll use this property\n * auto schema generation will not work properly anymore. Avoid using it.\n */\n columnDefinition?: string;\n\n /**\n * Column comment.\n */\n comment?: string;\n\n /**\n * Default database value.\n */\n default?: any;\n\n /**\n * ON UPDATE trigger. Works only for MySQL.\n */\n onUpdate?: string;\n\n /**\n * The precision for a decimal (exact numeric) column (applies only for decimal column), which is the maximum\n * number of digits that are stored for the values.\n */\n precision?: number;\n\n /**\n * The scale for a decimal (exact numeric) column (applies only for decimal column), which represents the number\n * of digits to the right of the decimal point and must not be greater than precision.\n */\n scale?: number;\n\n /**\n * Puts ZEROFILL attribute on to numeric column. Works only for MySQL.\n * If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column\n */\n zerofill?: boolean;\n\n /**\n * Puts UNSIGNED attribute on to numeric column. Works only for MySQL.\n */\n unsigned?: boolean;\n\n /**\n * Defines a column character set.\n * Not supported by all database types.\n */\n charset?: string;\n\n /**\n * Defines a column collation.\n */\n collation?: string;\n\n /**\n * Array of possible enumerated values.\n */\n enum?: any[]|Object;\n\n /**\n * Generated column expression. Supports only in MySQL.\n */\n asExpression?: string;\n\n /**\n * Generated column type. Supports only in MySQL.\n */\n generatedType?: \"VIRTUAL\"|\"STORED\";\n\n /**\n * Return type of HSTORE column.\n * Returns value as string or as object.\n */\n hstoreType?: \"object\"|\"string\";\n\n /**\n * Indicates if this column is an array.\n * Can be simply set to true or array length can be specified.\n * Supported only by postgres.\n */\n array?: boolean;\n\n /**\n * Specifies a value transformer that is to be used to (un)marshal\n * this column when reading or writing to the database.\n */\n transformer?: ValueTransformer|ValueTransformer[];\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,18 @@
1
+ import { EntitySchema } from "./EntitySchema";
2
+ export declare class EntitySchemaEmbeddedColumnOptions {
3
+ /**
4
+ * Schema of embedded entity
5
+ */
6
+ schema: EntitySchema;
7
+ /**
8
+ * Embedded column prefix.
9
+ * If set to empty string or false, then prefix is not set at all.
10
+ */
11
+ prefix?: string | boolean;
12
+ /**
13
+ * Indicates if this embedded is in array mode.
14
+ *
15
+ * This option works only in mongodb.
16
+ */
17
+ array?: boolean;
18
+ }
@@ -0,0 +1,8 @@
1
+ var EntitySchemaEmbeddedColumnOptions = /** @class */ (function () {
2
+ function EntitySchemaEmbeddedColumnOptions() {
3
+ }
4
+ return EntitySchemaEmbeddedColumnOptions;
5
+ }());
6
+ export { EntitySchemaEmbeddedColumnOptions };
7
+
8
+ //# sourceMappingURL=EntitySchemaEmbeddedColumnOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaEmbeddedColumnOptions.ts"],"names":[],"mappings":"AAEA;IAAA;IAkBA,CAAC;IAAD,wCAAC;AAAD,CAlBA,AAkBC,IAAA","file":"EntitySchemaEmbeddedColumnOptions.js","sourcesContent":["import { EntitySchema } from \"./EntitySchema\";\n\nexport class EntitySchemaEmbeddedColumnOptions {\n /**\n * Schema of embedded entity\n */\n schema: EntitySchema;\n\n /**\n * Embedded column prefix.\n * If set to empty string or false, then prefix is not set at all.\n */\n prefix?: string | boolean;\n\n /**\n * Indicates if this embedded is in array mode.\n *\n * This option works only in mongodb.\n */\n array?: boolean;\n}\n"],"sourceRoot":".."}
@@ -0,0 +1,6 @@
1
+ import { TypeORMError } from "../error";
2
+ export declare class EntitySchemaEmbeddedError extends TypeORMError {
3
+ static createEntitySchemaIsRequiredException(field: string): EntitySchemaEmbeddedError;
4
+ static createTargetIsRequired(field: string): EntitySchemaEmbeddedError;
5
+ constructor(message: string);
6
+ }
@@ -0,0 +1,18 @@
1
+ import { __extends } from "tslib";
2
+ import { TypeORMError } from "../error";
3
+ var EntitySchemaEmbeddedError = /** @class */ (function (_super) {
4
+ __extends(EntitySchemaEmbeddedError, _super);
5
+ function EntitySchemaEmbeddedError(message) {
6
+ return _super.call(this, message) || this;
7
+ }
8
+ EntitySchemaEmbeddedError.createEntitySchemaIsRequiredException = function (field) {
9
+ return new EntitySchemaEmbeddedError("EntitySchema is required for " + field + " embedded field");
10
+ };
11
+ EntitySchemaEmbeddedError.createTargetIsRequired = function (field) {
12
+ return new EntitySchemaEmbeddedError("Target field is required for " + field + " embedded EntitySchema");
13
+ };
14
+ return EntitySchemaEmbeddedError;
15
+ }(TypeORMError));
16
+ export { EntitySchemaEmbeddedError };
17
+
18
+ //# sourceMappingURL=EntitySchemaEmbeddedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaEmbeddedError.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC;IAA+C,6CAAY;IASvD,mCAAY,OAAe;eACvB,kBAAM,OAAO,CAAC;IAClB,CAAC;IAVM,+DAAqC,GAA5C,UAA6C,KAAa;QACtD,OAAO,IAAI,yBAAyB,CAAC,kCAAgC,KAAK,oBAAiB,CAAC,CAAC;IACjG,CAAC;IAEM,gDAAsB,GAA7B,UAA8B,KAAa;QACvC,OAAO,IAAI,yBAAyB,CAAC,kCAAgC,KAAK,2BAAwB,CAAC,CAAC;IACxG,CAAC;IAKL,gCAAC;AAAD,CAZA,AAYC,CAZ8C,YAAY,GAY1D","file":"EntitySchemaEmbeddedError.js","sourcesContent":["import { TypeORMError } from \"../error\";\n\nexport class EntitySchemaEmbeddedError extends TypeORMError {\n static createEntitySchemaIsRequiredException(field: string): EntitySchemaEmbeddedError {\n return new EntitySchemaEmbeddedError(`EntitySchema is required for ${field} embedded field`);\n }\n\n static createTargetIsRequired(field: string): EntitySchemaEmbeddedError {\n return new EntitySchemaEmbeddedError(`Target field is required for ${field} embedded EntitySchema`);\n }\n\n constructor(message: string) {\n super(message);\n }\n}\n"],"sourceRoot":".."}
@@ -1,4 +1,4 @@
1
- import { Connection, SelectQueryBuilder } from "..";
1
+ import { Connection, EntitySchemaEmbeddedColumnOptions, SelectQueryBuilder } from "..";
2
2
  import { EntitySchemaIndexOptions } from "./EntitySchemaIndexOptions";
3
3
  import { EntitySchemaColumnOptions } from "./EntitySchemaColumnOptions";
4
4
  import { EntitySchemaRelationOptions } from "./EntitySchemaRelationOptions";
@@ -71,6 +71,12 @@ export declare class EntitySchemaOptions<T> {
71
71
  * Entity exclusion options.
72
72
  */
73
73
  exclusions?: EntitySchemaExclusionOptions[];
74
+ /**
75
+ * Embedded Entities options
76
+ */
77
+ embeddeds?: {
78
+ [P in keyof Partial<T>]: EntitySchemaEmbeddedColumnOptions;
79
+ };
74
80
  /**
75
81
  * Indicates if schema synchronization is enabled or disabled for this entity.
76
82
  * If it will be set to false then schema sync will and migrations ignore this entity.
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaOptions.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH;IAAA;IA+FA,CAAC;IAAD,0BAAC;AAAD,CA/FA,AA+FC,IAAA","file":"EntitySchemaOptions.js","sourcesContent":["import {Connection, SelectQueryBuilder} from \"..\";\nimport {EntitySchemaIndexOptions} from \"./EntitySchemaIndexOptions\";\nimport {EntitySchemaColumnOptions} from \"./EntitySchemaColumnOptions\";\nimport {EntitySchemaRelationOptions} from \"./EntitySchemaRelationOptions\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\nimport {EntitySchemaUniqueOptions} from \"./EntitySchemaUniqueOptions\";\nimport {EntitySchemaCheckOptions} from \"./EntitySchemaCheckOptions\";\nimport {EntitySchemaExclusionOptions} from \"./EntitySchemaExclusionOptions\";\n\n/**\n * Interface for entity metadata mappings stored inside \"schemas\" instead of models decorated by decorators.\n */\nexport class EntitySchemaOptions<T> {\n\n /**\n * Name of the schema it extends.\n */\n extends?: string;\n\n /**\n * Target bind to this entity schema. Optional.\n */\n target?: Function;\n\n /**\n * Entity name.\n */\n name: string;\n\n /**\n * Table name.\n */\n tableName?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Table type.\n */\n type?: TableType;\n\n /**\n * Specifies a property name by which queries will perform ordering by default when fetching rows.\n */\n orderBy?: OrderByCondition;\n\n /**\n * Entity column's options.\n */\n columns: {\n [P in keyof T]?: EntitySchemaColumnOptions;\n };\n\n /**\n * Entity relation's options.\n */\n relations?: {\n [P in keyof T]?: EntitySchemaRelationOptions;\n };\n\n /**\n * Entity indices options.\n */\n indices?: EntitySchemaIndexOptions[];\n\n /**\n * Entity uniques options.\n */\n uniques?: EntitySchemaUniqueOptions[];\n\n /**\n * Entity check options.\n */\n checks?: EntitySchemaCheckOptions[];\n\n /**\n * Entity exclusion options.\n */\n exclusions?: EntitySchemaExclusionOptions[];\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation. \n * @see https://www.sqlite.org/withoutrowid.html. \n */\n withoutRowid?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/entity-schema/EntitySchemaOptions.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH;IAAA;IAsGA,CAAC;IAAD,0BAAC;AAAD,CAtGA,AAsGC,IAAA","file":"EntitySchemaOptions.js","sourcesContent":["import {Connection, EntitySchemaEmbeddedColumnOptions, SelectQueryBuilder} from \"..\";\nimport {EntitySchemaIndexOptions} from \"./EntitySchemaIndexOptions\";\nimport {EntitySchemaColumnOptions} from \"./EntitySchemaColumnOptions\";\nimport {EntitySchemaRelationOptions} from \"./EntitySchemaRelationOptions\";\nimport {OrderByCondition} from \"../find-options/OrderByCondition\";\nimport {TableType} from \"../metadata/types/TableTypes\";\nimport {EntitySchemaUniqueOptions} from \"./EntitySchemaUniqueOptions\";\nimport {EntitySchemaCheckOptions} from \"./EntitySchemaCheckOptions\";\nimport {EntitySchemaExclusionOptions} from \"./EntitySchemaExclusionOptions\";\n\n/**\n * Interface for entity metadata mappings stored inside \"schemas\" instead of models decorated by decorators.\n */\nexport class EntitySchemaOptions<T> {\n\n /**\n * Name of the schema it extends.\n */\n extends?: string;\n\n /**\n * Target bind to this entity schema. Optional.\n */\n target?: Function;\n\n /**\n * Entity name.\n */\n name: string;\n\n /**\n * Table name.\n */\n tableName?: string;\n\n /**\n * Database name. Used in MySql and Sql Server.\n */\n database?: string;\n\n /**\n * Schema name. Used in Postgres and Sql Server.\n */\n schema?: string;\n\n /**\n * Table type.\n */\n type?: TableType;\n\n /**\n * Specifies a property name by which queries will perform ordering by default when fetching rows.\n */\n orderBy?: OrderByCondition;\n\n /**\n * Entity column's options.\n */\n columns: {\n [P in keyof T]?: EntitySchemaColumnOptions;\n };\n\n /**\n * Entity relation's options.\n */\n relations?: {\n [P in keyof T]?: EntitySchemaRelationOptions;\n };\n\n /**\n * Entity indices options.\n */\n indices?: EntitySchemaIndexOptions[];\n\n /**\n * Entity uniques options.\n */\n uniques?: EntitySchemaUniqueOptions[];\n\n /**\n * Entity check options.\n */\n checks?: EntitySchemaCheckOptions[];\n\n /**\n * Entity exclusion options.\n */\n exclusions?: EntitySchemaExclusionOptions[];\n\n /**\n * Embedded Entities options\n */\n embeddeds?: {\n [P in keyof Partial<T>]: EntitySchemaEmbeddedColumnOptions;\n };\n\n /**\n * Indicates if schema synchronization is enabled or disabled for this entity.\n * If it will be set to false then schema sync will and migrations ignore this entity.\n * By default schema synchronization is enabled for all entities.\n */\n synchronize?: boolean;\n\n /**\n * If set to 'true' this option disables Sqlite's default behaviour of secretly creating\n * an integer primary key column named 'rowid' on table creation.\n * @see https://www.sqlite.org/withoutrowid.html.\n */\n withoutRowid?: boolean;\n\n /**\n * View expression.\n */\n expression?: string|((connection: Connection) => SelectQueryBuilder<any>);\n\n}\n"],"sourceRoot":".."}
@@ -9,4 +9,5 @@ export declare class EntitySchemaTransformer {
9
9
  * Transforms entity schema into new metadata args storage object.
10
10
  */
11
11
  transform(schemas: EntitySchema<any>[]): MetadataArgsStorage;
12
+ private transformColumnsRecursive;
12
13
  }
@@ -1,5 +1,6 @@
1
1
  import { __values } from "tslib";
2
2
  import { MetadataArgsStorage } from "../metadata-args/MetadataArgsStorage";
3
+ import { EntitySchemaEmbeddedError } from "./EntitySchemaEmbeddedError";
3
4
  /**
4
5
  * Transforms entity schema into metadata args storage.
5
6
  * The result will be just like entities read from decorators.
@@ -14,6 +15,7 @@ var EntitySchemaTransformer = /** @class */ (function () {
14
15
  * Transforms entity schema into new metadata args storage object.
15
16
  */
16
17
  EntitySchemaTransformer.prototype.transform = function (schemas) {
18
+ var _this = this;
17
19
  var metadataArgsStorage = new MetadataArgsStorage();
18
20
  schemas.forEach(function (entitySchema) {
19
21
  var options = entitySchema.options;
@@ -30,209 +32,233 @@ var EntitySchemaTransformer = /** @class */ (function () {
30
32
  expression: options.expression
31
33
  };
32
34
  metadataArgsStorage.tables.push(tableMetadata);
33
- // add columns metadata args from the schema
34
- Object.keys(options.columns).forEach(function (columnName) {
35
- var column = options.columns[columnName];
36
- var mode = "regular";
37
- if (column.createDate)
38
- mode = "createDate";
39
- if (column.updateDate)
40
- mode = "updateDate";
41
- if (column.deleteDate)
42
- mode = "deleteDate";
43
- if (column.version)
44
- mode = "version";
45
- if (column.treeChildrenCount)
46
- mode = "treeChildrenCount";
47
- if (column.treeLevel)
48
- mode = "treeLevel";
49
- if (column.objectId)
50
- mode = "objectId";
51
- var columnAgrs = {
35
+ _this.transformColumnsRecursive(options, metadataArgsStorage);
36
+ });
37
+ return metadataArgsStorage;
38
+ };
39
+ EntitySchemaTransformer.prototype.transformColumnsRecursive = function (options, metadataArgsStorage) {
40
+ var _this = this;
41
+ // add columns metadata args from the schema
42
+ Object.keys(options.columns).forEach(function (columnName) {
43
+ var column = options.columns[columnName];
44
+ var regularColumn = column;
45
+ var mode = "regular";
46
+ if (regularColumn.createDate)
47
+ mode = "createDate";
48
+ if (regularColumn.updateDate)
49
+ mode = "updateDate";
50
+ if (regularColumn.deleteDate)
51
+ mode = "deleteDate";
52
+ if (regularColumn.version)
53
+ mode = "version";
54
+ if (regularColumn.treeChildrenCount)
55
+ mode = "treeChildrenCount";
56
+ if (regularColumn.treeLevel)
57
+ mode = "treeLevel";
58
+ if (regularColumn.objectId)
59
+ mode = "objectId";
60
+ var columnAgrs = {
61
+ target: options.target || options.name,
62
+ mode: mode,
63
+ propertyName: columnName,
64
+ options: {
65
+ type: regularColumn.type,
66
+ name: regularColumn.objectId ? "_id" : regularColumn.name,
67
+ length: regularColumn.length,
68
+ width: regularColumn.width,
69
+ nullable: regularColumn.nullable,
70
+ readonly: regularColumn.readonly,
71
+ update: regularColumn.update,
72
+ select: regularColumn.select,
73
+ insert: regularColumn.insert,
74
+ primary: regularColumn.primary,
75
+ unique: regularColumn.unique,
76
+ comment: regularColumn.comment,
77
+ default: regularColumn.default,
78
+ onUpdate: regularColumn.onUpdate,
79
+ precision: regularColumn.precision,
80
+ scale: regularColumn.scale,
81
+ zerofill: regularColumn.zerofill,
82
+ unsigned: regularColumn.unsigned,
83
+ charset: regularColumn.charset,
84
+ collation: regularColumn.collation,
85
+ enum: regularColumn.enum,
86
+ asExpression: regularColumn.asExpression,
87
+ generatedType: regularColumn.generatedType,
88
+ hstoreType: regularColumn.hstoreType,
89
+ array: regularColumn.array,
90
+ transformer: regularColumn.transformer,
91
+ spatialFeatureType: regularColumn.spatialFeatureType,
92
+ srid: regularColumn.srid
93
+ }
94
+ };
95
+ metadataArgsStorage.columns.push(columnAgrs);
96
+ if (regularColumn.generated) {
97
+ var generationArgs = {
52
98
  target: options.target || options.name,
53
- mode: mode,
54
99
  propertyName: columnName,
100
+ strategy: typeof regularColumn.generated === "string" ? regularColumn.generated : "increment"
101
+ };
102
+ metadataArgsStorage.generations.push(generationArgs);
103
+ }
104
+ if (regularColumn.unique)
105
+ metadataArgsStorage.uniques.push({
106
+ target: options.target || options.name,
107
+ columns: [columnName]
108
+ });
109
+ });
110
+ // add relation metadata args from the schema
111
+ if (options.relations) {
112
+ Object.keys(options.relations).forEach(function (relationName) {
113
+ var e_1, _a;
114
+ var relationSchema = options.relations[relationName];
115
+ var relation = {
116
+ target: options.target || options.name,
117
+ propertyName: relationName,
118
+ relationType: relationSchema.type,
119
+ isLazy: relationSchema.lazy || false,
120
+ type: relationSchema.target,
121
+ inverseSideProperty: relationSchema.inverseSide,
122
+ isTreeParent: relationSchema.treeParent,
123
+ isTreeChildren: relationSchema.treeChildren,
55
124
  options: {
56
- type: column.type,
57
- name: column.objectId ? "_id" : column.name,
58
- length: column.length,
59
- width: column.width,
60
- nullable: column.nullable,
61
- readonly: column.readonly,
62
- update: column.update,
63
- select: column.select,
64
- insert: column.insert,
65
- primary: column.primary,
66
- unique: column.unique,
67
- comment: column.comment,
68
- default: column.default,
69
- onUpdate: column.onUpdate,
70
- precision: column.precision,
71
- scale: column.scale,
72
- zerofill: column.zerofill,
73
- unsigned: column.unsigned,
74
- charset: column.charset,
75
- collation: column.collation,
76
- enum: column.enum,
77
- asExpression: column.asExpression,
78
- generatedType: column.generatedType,
79
- hstoreType: column.hstoreType,
80
- array: column.array,
81
- transformer: column.transformer,
82
- spatialFeatureType: column.spatialFeatureType,
83
- srid: column.srid
125
+ eager: relationSchema.eager || false,
126
+ cascade: relationSchema.cascade,
127
+ nullable: relationSchema.nullable,
128
+ onDelete: relationSchema.onDelete,
129
+ onUpdate: relationSchema.onUpdate,
130
+ deferrable: relationSchema.deferrable,
131
+ primary: relationSchema.primary,
132
+ createForeignKeyConstraints: relationSchema.createForeignKeyConstraints,
133
+ persistence: relationSchema.persistence,
134
+ orphanedRowAction: relationSchema.orphanedRowAction
84
135
  }
85
136
  };
86
- metadataArgsStorage.columns.push(columnAgrs);
87
- if (column.generated) {
88
- var generationArgs = {
89
- target: options.target || options.name,
90
- propertyName: columnName,
91
- strategy: typeof column.generated === "string" ? column.generated : "increment"
92
- };
93
- metadataArgsStorage.generations.push(generationArgs);
94
- }
95
- if (column.unique)
96
- metadataArgsStorage.uniques.push({ target: options.target || options.name, columns: [columnName] });
97
- });
98
- // add relation metadata args from the schema
99
- if (options.relations) {
100
- Object.keys(options.relations).forEach(function (relationName) {
101
- var e_1, _a;
102
- var relationSchema = options.relations[relationName];
103
- var relation = {
104
- target: options.target || options.name,
105
- propertyName: relationName,
106
- relationType: relationSchema.type,
107
- isLazy: relationSchema.lazy || false,
108
- type: relationSchema.target,
109
- inverseSideProperty: relationSchema.inverseSide,
110
- isTreeParent: relationSchema.treeParent,
111
- isTreeChildren: relationSchema.treeChildren,
112
- options: {
113
- eager: relationSchema.eager || false,
114
- cascade: relationSchema.cascade,
115
- nullable: relationSchema.nullable,
116
- onDelete: relationSchema.onDelete,
117
- onUpdate: relationSchema.onUpdate,
118
- deferrable: relationSchema.deferrable,
119
- primary: relationSchema.primary,
120
- createForeignKeyConstraints: relationSchema.createForeignKeyConstraints,
121
- persistence: relationSchema.persistence,
122
- orphanedRowAction: relationSchema.orphanedRowAction
123
- }
124
- };
125
- metadataArgsStorage.relations.push(relation);
126
- // add join column
127
- if (relationSchema.joinColumn) {
128
- if (typeof relationSchema.joinColumn === "boolean") {
129
- var joinColumn = {
130
- target: options.target || options.name,
131
- propertyName: relationName
132
- };
133
- metadataArgsStorage.joinColumns.push(joinColumn);
137
+ metadataArgsStorage.relations.push(relation);
138
+ // add join column
139
+ if (relationSchema.joinColumn) {
140
+ if (typeof relationSchema.joinColumn === "boolean") {
141
+ var joinColumn = {
142
+ target: options.target || options.name,
143
+ propertyName: relationName
144
+ };
145
+ metadataArgsStorage.joinColumns.push(joinColumn);
146
+ }
147
+ else {
148
+ var joinColumnsOptions = Array.isArray(relationSchema.joinColumn) ? relationSchema.joinColumn : [relationSchema.joinColumn];
149
+ try {
150
+ for (var joinColumnsOptions_1 = __values(joinColumnsOptions), joinColumnsOptions_1_1 = joinColumnsOptions_1.next(); !joinColumnsOptions_1_1.done; joinColumnsOptions_1_1 = joinColumnsOptions_1.next()) {
151
+ var joinColumnOption = joinColumnsOptions_1_1.value;
152
+ var joinColumn = {
153
+ target: options.target || options.name,
154
+ propertyName: relationName,
155
+ name: joinColumnOption.name,
156
+ referencedColumnName: joinColumnOption.referencedColumnName
157
+ };
158
+ metadataArgsStorage.joinColumns.push(joinColumn);
159
+ }
134
160
  }
135
- else {
136
- var joinColumnsOptions = Array.isArray(relationSchema.joinColumn) ? relationSchema.joinColumn : [relationSchema.joinColumn];
161
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
162
+ finally {
137
163
  try {
138
- for (var joinColumnsOptions_1 = __values(joinColumnsOptions), joinColumnsOptions_1_1 = joinColumnsOptions_1.next(); !joinColumnsOptions_1_1.done; joinColumnsOptions_1_1 = joinColumnsOptions_1.next()) {
139
- var joinColumnOption = joinColumnsOptions_1_1.value;
140
- var joinColumn = {
141
- target: options.target || options.name,
142
- propertyName: relationName,
143
- name: joinColumnOption.name,
144
- referencedColumnName: joinColumnOption.referencedColumnName
145
- };
146
- metadataArgsStorage.joinColumns.push(joinColumn);
147
- }
148
- }
149
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
150
- finally {
151
- try {
152
- if (joinColumnsOptions_1_1 && !joinColumnsOptions_1_1.done && (_a = joinColumnsOptions_1.return)) _a.call(joinColumnsOptions_1);
153
- }
154
- finally { if (e_1) throw e_1.error; }
164
+ if (joinColumnsOptions_1_1 && !joinColumnsOptions_1_1.done && (_a = joinColumnsOptions_1.return)) _a.call(joinColumnsOptions_1);
155
165
  }
166
+ finally { if (e_1) throw e_1.error; }
156
167
  }
157
168
  }
158
- // add join table
159
- if (relationSchema.joinTable) {
160
- if (typeof relationSchema.joinTable === "boolean") {
161
- var joinTable = {
162
- target: options.target || options.name,
163
- propertyName: relationName
164
- };
165
- metadataArgsStorage.joinTables.push(joinTable);
166
- }
167
- else {
168
- var joinTable = {
169
- target: options.target || options.name,
170
- propertyName: relationName,
171
- name: relationSchema.joinTable.name,
172
- database: relationSchema.joinTable.database,
173
- schema: relationSchema.joinTable.schema,
174
- joinColumns: (relationSchema.joinTable.joinColumn ? [relationSchema.joinTable.joinColumn] : relationSchema.joinTable.joinColumns),
175
- inverseJoinColumns: (relationSchema.joinTable.inverseJoinColumn ? [relationSchema.joinTable.inverseJoinColumn] : relationSchema.joinTable.inverseJoinColumns),
176
- };
177
- metadataArgsStorage.joinTables.push(joinTable);
178
- }
169
+ }
170
+ // add join table
171
+ if (relationSchema.joinTable) {
172
+ if (typeof relationSchema.joinTable === "boolean") {
173
+ var joinTable = {
174
+ target: options.target || options.name,
175
+ propertyName: relationName
176
+ };
177
+ metadataArgsStorage.joinTables.push(joinTable);
179
178
  }
179
+ else {
180
+ var joinTable = {
181
+ target: options.target || options.name,
182
+ propertyName: relationName,
183
+ name: relationSchema.joinTable.name,
184
+ database: relationSchema.joinTable.database,
185
+ schema: relationSchema.joinTable.schema,
186
+ joinColumns: (relationSchema.joinTable.joinColumn ? [relationSchema.joinTable.joinColumn] : relationSchema.joinTable.joinColumns),
187
+ inverseJoinColumns: (relationSchema.joinTable.inverseJoinColumn ? [relationSchema.joinTable.inverseJoinColumn] : relationSchema.joinTable.inverseJoinColumns),
188
+ };
189
+ metadataArgsStorage.joinTables.push(joinTable);
190
+ }
191
+ }
192
+ });
193
+ }
194
+ // add index metadata args from the schema
195
+ if (options.indices) {
196
+ options.indices.forEach(function (index) {
197
+ var indexAgrs = {
198
+ target: options.target || options.name,
199
+ name: index.name,
200
+ unique: index.unique === true ? true : false,
201
+ spatial: index.spatial === true ? true : false,
202
+ fulltext: index.fulltext === true ? true : false,
203
+ parser: index.parser,
204
+ synchronize: index.synchronize === false ? false : true,
205
+ where: index.where,
206
+ sparse: index.sparse,
207
+ columns: index.columns
208
+ };
209
+ metadataArgsStorage.indices.push(indexAgrs);
210
+ });
211
+ }
212
+ // add unique metadata args from the schema
213
+ if (options.uniques) {
214
+ options.uniques.forEach(function (unique) {
215
+ var uniqueAgrs = {
216
+ target: options.target || options.name,
217
+ name: unique.name,
218
+ columns: unique.columns,
219
+ deferrable: unique.deferrable,
220
+ };
221
+ metadataArgsStorage.uniques.push(uniqueAgrs);
222
+ });
223
+ }
224
+ // add check metadata args from the schema
225
+ if (options.checks) {
226
+ options.checks.forEach(function (check) {
227
+ var checkAgrs = {
228
+ target: options.target || options.name,
229
+ name: check.name,
230
+ expression: check.expression
231
+ };
232
+ metadataArgsStorage.checks.push(checkAgrs);
233
+ });
234
+ }
235
+ // add exclusion metadata args from the schema
236
+ if (options.exclusions) {
237
+ options.exclusions.forEach(function (exclusion) {
238
+ var exclusionArgs = {
239
+ target: options.target || options.name,
240
+ name: exclusion.name,
241
+ expression: exclusion.expression
242
+ };
243
+ metadataArgsStorage.exclusions.push(exclusionArgs);
244
+ });
245
+ }
246
+ if (options.embeddeds) {
247
+ Object.keys(options.embeddeds).forEach(function (columnName) {
248
+ var embeddedOptions = options.embeddeds[columnName];
249
+ if (!embeddedOptions.schema)
250
+ throw EntitySchemaEmbeddedError.createEntitySchemaIsRequiredException(columnName);
251
+ var embeddedSchema = embeddedOptions.schema.options;
252
+ metadataArgsStorage.embeddeds.push({
253
+ target: options.target || options.name,
254
+ propertyName: columnName,
255
+ isArray: embeddedOptions.array === true,
256
+ prefix: embeddedOptions.prefix !== undefined ? embeddedOptions.prefix : undefined,
257
+ type: function () { return (embeddedSchema === null || embeddedSchema === void 0 ? void 0 : embeddedSchema.target) || embeddedSchema.name; },
180
258
  });
181
- }
182
- // add index metadata args from the schema
183
- if (options.indices) {
184
- options.indices.forEach(function (index) {
185
- var indexAgrs = {
186
- target: options.target || options.name,
187
- name: index.name,
188
- unique: index.unique === true ? true : false,
189
- spatial: index.spatial === true ? true : false,
190
- fulltext: index.fulltext === true ? true : false,
191
- parser: index.parser,
192
- synchronize: index.synchronize === false ? false : true,
193
- where: index.where,
194
- sparse: index.sparse,
195
- columns: index.columns
196
- };
197
- metadataArgsStorage.indices.push(indexAgrs);
198
- });
199
- }
200
- // add unique metadata args from the schema
201
- if (options.uniques) {
202
- options.uniques.forEach(function (unique) {
203
- var uniqueAgrs = {
204
- target: options.target || options.name,
205
- name: unique.name,
206
- columns: unique.columns,
207
- deferrable: unique.deferrable,
208
- };
209
- metadataArgsStorage.uniques.push(uniqueAgrs);
210
- });
211
- }
212
- // add check metadata args from the schema
213
- if (options.checks) {
214
- options.checks.forEach(function (check) {
215
- var checkAgrs = {
216
- target: options.target || options.name,
217
- name: check.name,
218
- expression: check.expression
219
- };
220
- metadataArgsStorage.checks.push(checkAgrs);
221
- });
222
- }
223
- // add exclusion metadata args from the schema
224
- if (options.exclusions) {
225
- options.exclusions.forEach(function (exclusion) {
226
- var exclusionArgs = {
227
- target: options.target || options.name,
228
- name: exclusion.name,
229
- expression: exclusion.expression
230
- };
231
- metadataArgsStorage.exclusions.push(exclusionArgs);
232
- });
233
- }
234
- });
235
- return metadataArgsStorage;
259
+ _this.transformColumnsRecursive(embeddedSchema, metadataArgsStorage);
260
+ });
261
+ }
236
262
  };
237
263
  return EntitySchemaTransformer;
238
264
  }());