typeorm 0.2.43-dev.a24d48a → 0.2.44-dev.1f54c70

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 (58) hide show
  1. package/browser/driver/sap/SapQueryRunner.js +12 -0
  2. package/browser/driver/sap/SapQueryRunner.js.map +1 -1
  3. package/browser/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  4. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.d.ts +18 -0
  5. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.js +8 -0
  6. package/browser/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -0
  7. package/browser/entity-schema/EntitySchemaEmbeddedError.d.ts +6 -0
  8. package/browser/entity-schema/EntitySchemaEmbeddedError.js +18 -0
  9. package/browser/entity-schema/EntitySchemaEmbeddedError.js.map +1 -0
  10. package/browser/entity-schema/EntitySchemaOptions.d.ts +7 -1
  11. package/browser/entity-schema/EntitySchemaOptions.js.map +1 -1
  12. package/browser/entity-schema/EntitySchemaTransformer.d.ts +1 -0
  13. package/browser/entity-schema/EntitySchemaTransformer.js +217 -191
  14. package/browser/entity-schema/EntitySchemaTransformer.js.map +1 -1
  15. package/browser/index.d.ts +1 -0
  16. package/browser/index.js +1 -0
  17. package/browser/index.js.map +1 -1
  18. package/browser/metadata/EmbeddedMetadata.d.ts +1 -1
  19. package/browser/metadata/EmbeddedMetadata.js +3 -0
  20. package/browser/metadata/EmbeddedMetadata.js.map +1 -1
  21. package/browser/metadata-args/EmbeddedMetadataArgs.d.ts +2 -2
  22. package/browser/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
  23. package/browser/metadata-builder/EntityMetadataBuilder.js +3 -1
  24. package/browser/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  25. package/browser/query-builder/RelationLoader.js +1 -1
  26. package/browser/query-builder/RelationLoader.js.map +1 -1
  27. package/browser/util/ImportUtils.js +2 -1
  28. package/browser/util/ImportUtils.js.map +1 -1
  29. package/driver/sap/SapQueryRunner.js +12 -0
  30. package/driver/sap/SapQueryRunner.js.map +1 -1
  31. package/entity-schema/EntitySchemaColumnOptions.js.map +1 -1
  32. package/entity-schema/EntitySchemaEmbeddedColumnOptions.d.ts +18 -0
  33. package/entity-schema/EntitySchemaEmbeddedColumnOptions.js +11 -0
  34. package/entity-schema/EntitySchemaEmbeddedColumnOptions.js.map +1 -0
  35. package/entity-schema/EntitySchemaEmbeddedError.d.ts +6 -0
  36. package/entity-schema/EntitySchemaEmbeddedError.js +21 -0
  37. package/entity-schema/EntitySchemaEmbeddedError.js.map +1 -0
  38. package/entity-schema/EntitySchemaOptions.d.ts +7 -1
  39. package/entity-schema/EntitySchemaOptions.js.map +1 -1
  40. package/entity-schema/EntitySchemaTransformer.d.ts +1 -0
  41. package/entity-schema/EntitySchemaTransformer.js +217 -191
  42. package/entity-schema/EntitySchemaTransformer.js.map +1 -1
  43. package/index.d.ts +1 -0
  44. package/index.js +3 -1
  45. package/index.js.map +1 -1
  46. package/index.mjs +2 -0
  47. package/metadata/EmbeddedMetadata.d.ts +1 -1
  48. package/metadata/EmbeddedMetadata.js +3 -0
  49. package/metadata/EmbeddedMetadata.js.map +1 -1
  50. package/metadata-args/EmbeddedMetadataArgs.d.ts +2 -2
  51. package/metadata-args/EmbeddedMetadataArgs.js.map +1 -1
  52. package/metadata-builder/EntityMetadataBuilder.js +3 -1
  53. package/metadata-builder/EntityMetadataBuilder.js.map +1 -1
  54. package/package.json +1 -1
  55. package/query-builder/RelationLoader.js +5 -5
  56. package/query-builder/RelationLoader.js.map +1 -1
  57. package/util/ImportUtils.js +2 -1
  58. package/util/ImportUtils.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../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":["../../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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntitySchemaEmbeddedColumnOptions = void 0;
4
+ var EntitySchemaEmbeddedColumnOptions = /** @class */ (function () {
5
+ function EntitySchemaEmbeddedColumnOptions() {
6
+ }
7
+ return EntitySchemaEmbeddedColumnOptions;
8
+ }());
9
+ exports.EntitySchemaEmbeddedColumnOptions = EntitySchemaEmbeddedColumnOptions;
10
+
11
+ //# sourceMappingURL=EntitySchemaEmbeddedColumnOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/entity-schema/EntitySchemaEmbeddedColumnOptions.ts"],"names":[],"mappings":";;;AAEA;IAAA;IAkBA,CAAC;IAAD,wCAAC;AAAD,CAlBA,AAkBC,IAAA;AAlBY,8EAAiC","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,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntitySchemaEmbeddedError = void 0;
4
+ var tslib_1 = require("tslib");
5
+ var error_1 = require("../error");
6
+ var EntitySchemaEmbeddedError = /** @class */ (function (_super) {
7
+ (0, tslib_1.__extends)(EntitySchemaEmbeddedError, _super);
8
+ function EntitySchemaEmbeddedError(message) {
9
+ return _super.call(this, message) || this;
10
+ }
11
+ EntitySchemaEmbeddedError.createEntitySchemaIsRequiredException = function (field) {
12
+ return new EntitySchemaEmbeddedError("EntitySchema is required for " + field + " embedded field");
13
+ };
14
+ EntitySchemaEmbeddedError.createTargetIsRequired = function (field) {
15
+ return new EntitySchemaEmbeddedError("Target field is required for " + field + " embedded EntitySchema");
16
+ };
17
+ return EntitySchemaEmbeddedError;
18
+ }(error_1.TypeORMError));
19
+ exports.EntitySchemaEmbeddedError = EntitySchemaEmbeddedError;
20
+
21
+ //# sourceMappingURL=EntitySchemaEmbeddedError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/entity-schema/EntitySchemaEmbeddedError.ts"],"names":[],"mappings":";;;;AAAA,kCAAwC;AAExC;IAA+C,0DAAY;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,oBAAY,GAY1D;AAZY,8DAAyB","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":["../../src/entity-schema/EntitySchemaOptions.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH;IAAA;IA+FA,CAAC;IAAD,0BAAC;AAAD,CA/FA,AA+FC,IAAA;AA/FY,kDAAmB","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":["../../src/entity-schema/EntitySchemaOptions.ts"],"names":[],"mappings":";;;AAUA;;GAEG;AACH;IAAA;IAsGA,CAAC;IAAD,0BAAC;AAAD,CAtGA,AAsGC,IAAA;AAtGY,kDAAmB","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
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EntitySchemaTransformer = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var MetadataArgsStorage_1 = require("../metadata-args/MetadataArgsStorage");
6
+ var EntitySchemaEmbeddedError_1 = require("./EntitySchemaEmbeddedError");
6
7
  /**
7
8
  * Transforms entity schema into metadata args storage.
8
9
  * The result will be just like entities read from decorators.
@@ -17,6 +18,7 @@ var EntitySchemaTransformer = /** @class */ (function () {
17
18
  * Transforms entity schema into new metadata args storage object.
18
19
  */
19
20
  EntitySchemaTransformer.prototype.transform = function (schemas) {
21
+ var _this = this;
20
22
  var metadataArgsStorage = new MetadataArgsStorage_1.MetadataArgsStorage();
21
23
  schemas.forEach(function (entitySchema) {
22
24
  var options = entitySchema.options;
@@ -33,209 +35,233 @@ var EntitySchemaTransformer = /** @class */ (function () {
33
35
  expression: options.expression
34
36
  };
35
37
  metadataArgsStorage.tables.push(tableMetadata);
36
- // add columns metadata args from the schema
37
- Object.keys(options.columns).forEach(function (columnName) {
38
- var column = options.columns[columnName];
39
- var mode = "regular";
40
- if (column.createDate)
41
- mode = "createDate";
42
- if (column.updateDate)
43
- mode = "updateDate";
44
- if (column.deleteDate)
45
- mode = "deleteDate";
46
- if (column.version)
47
- mode = "version";
48
- if (column.treeChildrenCount)
49
- mode = "treeChildrenCount";
50
- if (column.treeLevel)
51
- mode = "treeLevel";
52
- if (column.objectId)
53
- mode = "objectId";
54
- var columnAgrs = {
38
+ _this.transformColumnsRecursive(options, metadataArgsStorage);
39
+ });
40
+ return metadataArgsStorage;
41
+ };
42
+ EntitySchemaTransformer.prototype.transformColumnsRecursive = function (options, metadataArgsStorage) {
43
+ var _this = this;
44
+ // add columns metadata args from the schema
45
+ Object.keys(options.columns).forEach(function (columnName) {
46
+ var column = options.columns[columnName];
47
+ var regularColumn = column;
48
+ var mode = "regular";
49
+ if (regularColumn.createDate)
50
+ mode = "createDate";
51
+ if (regularColumn.updateDate)
52
+ mode = "updateDate";
53
+ if (regularColumn.deleteDate)
54
+ mode = "deleteDate";
55
+ if (regularColumn.version)
56
+ mode = "version";
57
+ if (regularColumn.treeChildrenCount)
58
+ mode = "treeChildrenCount";
59
+ if (regularColumn.treeLevel)
60
+ mode = "treeLevel";
61
+ if (regularColumn.objectId)
62
+ mode = "objectId";
63
+ var columnAgrs = {
64
+ target: options.target || options.name,
65
+ mode: mode,
66
+ propertyName: columnName,
67
+ options: {
68
+ type: regularColumn.type,
69
+ name: regularColumn.objectId ? "_id" : regularColumn.name,
70
+ length: regularColumn.length,
71
+ width: regularColumn.width,
72
+ nullable: regularColumn.nullable,
73
+ readonly: regularColumn.readonly,
74
+ update: regularColumn.update,
75
+ select: regularColumn.select,
76
+ insert: regularColumn.insert,
77
+ primary: regularColumn.primary,
78
+ unique: regularColumn.unique,
79
+ comment: regularColumn.comment,
80
+ default: regularColumn.default,
81
+ onUpdate: regularColumn.onUpdate,
82
+ precision: regularColumn.precision,
83
+ scale: regularColumn.scale,
84
+ zerofill: regularColumn.zerofill,
85
+ unsigned: regularColumn.unsigned,
86
+ charset: regularColumn.charset,
87
+ collation: regularColumn.collation,
88
+ enum: regularColumn.enum,
89
+ asExpression: regularColumn.asExpression,
90
+ generatedType: regularColumn.generatedType,
91
+ hstoreType: regularColumn.hstoreType,
92
+ array: regularColumn.array,
93
+ transformer: regularColumn.transformer,
94
+ spatialFeatureType: regularColumn.spatialFeatureType,
95
+ srid: regularColumn.srid
96
+ }
97
+ };
98
+ metadataArgsStorage.columns.push(columnAgrs);
99
+ if (regularColumn.generated) {
100
+ var generationArgs = {
55
101
  target: options.target || options.name,
56
- mode: mode,
57
102
  propertyName: columnName,
103
+ strategy: typeof regularColumn.generated === "string" ? regularColumn.generated : "increment"
104
+ };
105
+ metadataArgsStorage.generations.push(generationArgs);
106
+ }
107
+ if (regularColumn.unique)
108
+ metadataArgsStorage.uniques.push({
109
+ target: options.target || options.name,
110
+ columns: [columnName]
111
+ });
112
+ });
113
+ // add relation metadata args from the schema
114
+ if (options.relations) {
115
+ Object.keys(options.relations).forEach(function (relationName) {
116
+ var e_1, _a;
117
+ var relationSchema = options.relations[relationName];
118
+ var relation = {
119
+ target: options.target || options.name,
120
+ propertyName: relationName,
121
+ relationType: relationSchema.type,
122
+ isLazy: relationSchema.lazy || false,
123
+ type: relationSchema.target,
124
+ inverseSideProperty: relationSchema.inverseSide,
125
+ isTreeParent: relationSchema.treeParent,
126
+ isTreeChildren: relationSchema.treeChildren,
58
127
  options: {
59
- type: column.type,
60
- name: column.objectId ? "_id" : column.name,
61
- length: column.length,
62
- width: column.width,
63
- nullable: column.nullable,
64
- readonly: column.readonly,
65
- update: column.update,
66
- select: column.select,
67
- insert: column.insert,
68
- primary: column.primary,
69
- unique: column.unique,
70
- comment: column.comment,
71
- default: column.default,
72
- onUpdate: column.onUpdate,
73
- precision: column.precision,
74
- scale: column.scale,
75
- zerofill: column.zerofill,
76
- unsigned: column.unsigned,
77
- charset: column.charset,
78
- collation: column.collation,
79
- enum: column.enum,
80
- asExpression: column.asExpression,
81
- generatedType: column.generatedType,
82
- hstoreType: column.hstoreType,
83
- array: column.array,
84
- transformer: column.transformer,
85
- spatialFeatureType: column.spatialFeatureType,
86
- srid: column.srid
128
+ eager: relationSchema.eager || false,
129
+ cascade: relationSchema.cascade,
130
+ nullable: relationSchema.nullable,
131
+ onDelete: relationSchema.onDelete,
132
+ onUpdate: relationSchema.onUpdate,
133
+ deferrable: relationSchema.deferrable,
134
+ primary: relationSchema.primary,
135
+ createForeignKeyConstraints: relationSchema.createForeignKeyConstraints,
136
+ persistence: relationSchema.persistence,
137
+ orphanedRowAction: relationSchema.orphanedRowAction
87
138
  }
88
139
  };
89
- metadataArgsStorage.columns.push(columnAgrs);
90
- if (column.generated) {
91
- var generationArgs = {
92
- target: options.target || options.name,
93
- propertyName: columnName,
94
- strategy: typeof column.generated === "string" ? column.generated : "increment"
95
- };
96
- metadataArgsStorage.generations.push(generationArgs);
97
- }
98
- if (column.unique)
99
- metadataArgsStorage.uniques.push({ target: options.target || options.name, columns: [columnName] });
100
- });
101
- // add relation metadata args from the schema
102
- if (options.relations) {
103
- Object.keys(options.relations).forEach(function (relationName) {
104
- var e_1, _a;
105
- var relationSchema = options.relations[relationName];
106
- var relation = {
107
- target: options.target || options.name,
108
- propertyName: relationName,
109
- relationType: relationSchema.type,
110
- isLazy: relationSchema.lazy || false,
111
- type: relationSchema.target,
112
- inverseSideProperty: relationSchema.inverseSide,
113
- isTreeParent: relationSchema.treeParent,
114
- isTreeChildren: relationSchema.treeChildren,
115
- options: {
116
- eager: relationSchema.eager || false,
117
- cascade: relationSchema.cascade,
118
- nullable: relationSchema.nullable,
119
- onDelete: relationSchema.onDelete,
120
- onUpdate: relationSchema.onUpdate,
121
- deferrable: relationSchema.deferrable,
122
- primary: relationSchema.primary,
123
- createForeignKeyConstraints: relationSchema.createForeignKeyConstraints,
124
- persistence: relationSchema.persistence,
125
- orphanedRowAction: relationSchema.orphanedRowAction
126
- }
127
- };
128
- metadataArgsStorage.relations.push(relation);
129
- // add join column
130
- if (relationSchema.joinColumn) {
131
- if (typeof relationSchema.joinColumn === "boolean") {
132
- var joinColumn = {
133
- target: options.target || options.name,
134
- propertyName: relationName
135
- };
136
- metadataArgsStorage.joinColumns.push(joinColumn);
140
+ metadataArgsStorage.relations.push(relation);
141
+ // add join column
142
+ if (relationSchema.joinColumn) {
143
+ if (typeof relationSchema.joinColumn === "boolean") {
144
+ var joinColumn = {
145
+ target: options.target || options.name,
146
+ propertyName: relationName
147
+ };
148
+ metadataArgsStorage.joinColumns.push(joinColumn);
149
+ }
150
+ else {
151
+ var joinColumnsOptions = Array.isArray(relationSchema.joinColumn) ? relationSchema.joinColumn : [relationSchema.joinColumn];
152
+ try {
153
+ for (var joinColumnsOptions_1 = (0, tslib_1.__values)(joinColumnsOptions), joinColumnsOptions_1_1 = joinColumnsOptions_1.next(); !joinColumnsOptions_1_1.done; joinColumnsOptions_1_1 = joinColumnsOptions_1.next()) {
154
+ var joinColumnOption = joinColumnsOptions_1_1.value;
155
+ var joinColumn = {
156
+ target: options.target || options.name,
157
+ propertyName: relationName,
158
+ name: joinColumnOption.name,
159
+ referencedColumnName: joinColumnOption.referencedColumnName
160
+ };
161
+ metadataArgsStorage.joinColumns.push(joinColumn);
162
+ }
137
163
  }
138
- else {
139
- var joinColumnsOptions = Array.isArray(relationSchema.joinColumn) ? relationSchema.joinColumn : [relationSchema.joinColumn];
164
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
165
+ finally {
140
166
  try {
141
- for (var joinColumnsOptions_1 = (0, tslib_1.__values)(joinColumnsOptions), joinColumnsOptions_1_1 = joinColumnsOptions_1.next(); !joinColumnsOptions_1_1.done; joinColumnsOptions_1_1 = joinColumnsOptions_1.next()) {
142
- var joinColumnOption = joinColumnsOptions_1_1.value;
143
- var joinColumn = {
144
- target: options.target || options.name,
145
- propertyName: relationName,
146
- name: joinColumnOption.name,
147
- referencedColumnName: joinColumnOption.referencedColumnName
148
- };
149
- metadataArgsStorage.joinColumns.push(joinColumn);
150
- }
151
- }
152
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
153
- finally {
154
- try {
155
- if (joinColumnsOptions_1_1 && !joinColumnsOptions_1_1.done && (_a = joinColumnsOptions_1.return)) _a.call(joinColumnsOptions_1);
156
- }
157
- finally { if (e_1) throw e_1.error; }
167
+ if (joinColumnsOptions_1_1 && !joinColumnsOptions_1_1.done && (_a = joinColumnsOptions_1.return)) _a.call(joinColumnsOptions_1);
158
168
  }
169
+ finally { if (e_1) throw e_1.error; }
159
170
  }
160
171
  }
161
- // add join table
162
- if (relationSchema.joinTable) {
163
- if (typeof relationSchema.joinTable === "boolean") {
164
- var joinTable = {
165
- target: options.target || options.name,
166
- propertyName: relationName
167
- };
168
- metadataArgsStorage.joinTables.push(joinTable);
169
- }
170
- else {
171
- var joinTable = {
172
- target: options.target || options.name,
173
- propertyName: relationName,
174
- name: relationSchema.joinTable.name,
175
- database: relationSchema.joinTable.database,
176
- schema: relationSchema.joinTable.schema,
177
- joinColumns: (relationSchema.joinTable.joinColumn ? [relationSchema.joinTable.joinColumn] : relationSchema.joinTable.joinColumns),
178
- inverseJoinColumns: (relationSchema.joinTable.inverseJoinColumn ? [relationSchema.joinTable.inverseJoinColumn] : relationSchema.joinTable.inverseJoinColumns),
179
- };
180
- metadataArgsStorage.joinTables.push(joinTable);
181
- }
172
+ }
173
+ // add join table
174
+ if (relationSchema.joinTable) {
175
+ if (typeof relationSchema.joinTable === "boolean") {
176
+ var joinTable = {
177
+ target: options.target || options.name,
178
+ propertyName: relationName
179
+ };
180
+ metadataArgsStorage.joinTables.push(joinTable);
182
181
  }
182
+ else {
183
+ var joinTable = {
184
+ target: options.target || options.name,
185
+ propertyName: relationName,
186
+ name: relationSchema.joinTable.name,
187
+ database: relationSchema.joinTable.database,
188
+ schema: relationSchema.joinTable.schema,
189
+ joinColumns: (relationSchema.joinTable.joinColumn ? [relationSchema.joinTable.joinColumn] : relationSchema.joinTable.joinColumns),
190
+ inverseJoinColumns: (relationSchema.joinTable.inverseJoinColumn ? [relationSchema.joinTable.inverseJoinColumn] : relationSchema.joinTable.inverseJoinColumns),
191
+ };
192
+ metadataArgsStorage.joinTables.push(joinTable);
193
+ }
194
+ }
195
+ });
196
+ }
197
+ // add index metadata args from the schema
198
+ if (options.indices) {
199
+ options.indices.forEach(function (index) {
200
+ var indexAgrs = {
201
+ target: options.target || options.name,
202
+ name: index.name,
203
+ unique: index.unique === true ? true : false,
204
+ spatial: index.spatial === true ? true : false,
205
+ fulltext: index.fulltext === true ? true : false,
206
+ parser: index.parser,
207
+ synchronize: index.synchronize === false ? false : true,
208
+ where: index.where,
209
+ sparse: index.sparse,
210
+ columns: index.columns
211
+ };
212
+ metadataArgsStorage.indices.push(indexAgrs);
213
+ });
214
+ }
215
+ // add unique metadata args from the schema
216
+ if (options.uniques) {
217
+ options.uniques.forEach(function (unique) {
218
+ var uniqueAgrs = {
219
+ target: options.target || options.name,
220
+ name: unique.name,
221
+ columns: unique.columns,
222
+ deferrable: unique.deferrable,
223
+ };
224
+ metadataArgsStorage.uniques.push(uniqueAgrs);
225
+ });
226
+ }
227
+ // add check metadata args from the schema
228
+ if (options.checks) {
229
+ options.checks.forEach(function (check) {
230
+ var checkAgrs = {
231
+ target: options.target || options.name,
232
+ name: check.name,
233
+ expression: check.expression
234
+ };
235
+ metadataArgsStorage.checks.push(checkAgrs);
236
+ });
237
+ }
238
+ // add exclusion metadata args from the schema
239
+ if (options.exclusions) {
240
+ options.exclusions.forEach(function (exclusion) {
241
+ var exclusionArgs = {
242
+ target: options.target || options.name,
243
+ name: exclusion.name,
244
+ expression: exclusion.expression
245
+ };
246
+ metadataArgsStorage.exclusions.push(exclusionArgs);
247
+ });
248
+ }
249
+ if (options.embeddeds) {
250
+ Object.keys(options.embeddeds).forEach(function (columnName) {
251
+ var embeddedOptions = options.embeddeds[columnName];
252
+ if (!embeddedOptions.schema)
253
+ throw EntitySchemaEmbeddedError_1.EntitySchemaEmbeddedError.createEntitySchemaIsRequiredException(columnName);
254
+ var embeddedSchema = embeddedOptions.schema.options;
255
+ metadataArgsStorage.embeddeds.push({
256
+ target: options.target || options.name,
257
+ propertyName: columnName,
258
+ isArray: embeddedOptions.array === true,
259
+ prefix: embeddedOptions.prefix !== undefined ? embeddedOptions.prefix : undefined,
260
+ type: function () { return (embeddedSchema === null || embeddedSchema === void 0 ? void 0 : embeddedSchema.target) || embeddedSchema.name; },
183
261
  });
184
- }
185
- // add index metadata args from the schema
186
- if (options.indices) {
187
- options.indices.forEach(function (index) {
188
- var indexAgrs = {
189
- target: options.target || options.name,
190
- name: index.name,
191
- unique: index.unique === true ? true : false,
192
- spatial: index.spatial === true ? true : false,
193
- fulltext: index.fulltext === true ? true : false,
194
- parser: index.parser,
195
- synchronize: index.synchronize === false ? false : true,
196
- where: index.where,
197
- sparse: index.sparse,
198
- columns: index.columns
199
- };
200
- metadataArgsStorage.indices.push(indexAgrs);
201
- });
202
- }
203
- // add unique metadata args from the schema
204
- if (options.uniques) {
205
- options.uniques.forEach(function (unique) {
206
- var uniqueAgrs = {
207
- target: options.target || options.name,
208
- name: unique.name,
209
- columns: unique.columns,
210
- deferrable: unique.deferrable,
211
- };
212
- metadataArgsStorage.uniques.push(uniqueAgrs);
213
- });
214
- }
215
- // add check metadata args from the schema
216
- if (options.checks) {
217
- options.checks.forEach(function (check) {
218
- var checkAgrs = {
219
- target: options.target || options.name,
220
- name: check.name,
221
- expression: check.expression
222
- };
223
- metadataArgsStorage.checks.push(checkAgrs);
224
- });
225
- }
226
- // add exclusion metadata args from the schema
227
- if (options.exclusions) {
228
- options.exclusions.forEach(function (exclusion) {
229
- var exclusionArgs = {
230
- target: options.target || options.name,
231
- name: exclusion.name,
232
- expression: exclusion.expression
233
- };
234
- metadataArgsStorage.exclusions.push(exclusionArgs);
235
- });
236
- }
237
- });
238
- return metadataArgsStorage;
262
+ _this.transformColumnsRecursive(embeddedSchema, metadataArgsStorage);
263
+ });
264
+ }
239
265
  };
240
266
  return EntitySchemaTransformer;
241
267
  }());